Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Commit

Permalink
fix(backend): report file urls for file system
Browse files Browse the repository at this point in the history
Starting with v10, Node uses file urls in inspector protocol.
Breakpoints work iff file path reported using file url.
Otherwise provisional breakpoint will use path with spaces,
instead of %20.

Bug: #204
  • Loading branch information
alexkozy committed Jul 10, 2019
1 parent eafb0a9 commit d8f84ef
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions services/file_system.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
const fs = require('fs');
const url = require('url');

const { rpc, rpc_process } = require('carlo/rpc');
const chokidar = require('chokidar');

let pathToUrl;
if (!url.pathToFileURL) {
// Node 8 does not convert file paths to file urls.
pathToUrl = str => str;
} else {
pathToUrl = function(fileName) {
if (url.pathToFileURL)
return url.pathToFileURL(fileName).toString();
}
}

class FileSystemHandler {
constructor() {
require('../lib/process_utility.js')('file_system', () => this.dispose());
Expand All @@ -26,7 +38,7 @@ class FileSystemHandler {
setTimeout(() => client.filesChanged(events.splice(0)), 100);
events.push({
type: event,
name: name
name: pathToUrl(name)
});
}
});
Expand All @@ -35,7 +47,7 @@ class FileSystemHandler {

forceFileLoad(fileName) {
if (fileName.startsWith(this._embedderPath) && fs.existsSync(fileName))
this._client.filesChanged([{type: 'add', name: fileName}]);
this._client.filesChanged([{type: 'add', name: pathToUrl(fileName)}]);
}

dispose() {
Expand Down

0 comments on commit d8f84ef

Please sign in to comment.