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

fix(backend): copy to preload.js to tmp dir to avoid spaces in path #90

Merged
merged 1 commit into from
Aug 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion front_end/ndb/NdbMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,8 @@ Ndb.NodeProcessManager = class extends Common.Object {
execPath, args, options: {
waitAtStart: true,
data: debugId,
cwd: NdbProcessInfo.cwd
cwd: NdbProcessInfo.cwd,
preload: NdbProcessInfo.preload
}
});
}
Expand Down
3 changes: 2 additions & 1 deletion front_end/ndb_ui/Terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ Ndb.Terminal = class extends UI.VBox {
const {error} = await this._service.call('init', {
cols: this._terminal.cols,
rows: this._terminal.rows,
nddStore: nddStore
nddStore: nddStore,
preload: NdbProcessInfo.preload
});
this._ready = true;
if (this._buffer.length) {
Expand Down
8 changes: 6 additions & 2 deletions lib/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ const fsWriteFile = util.promisify(fs.writeFile);
async function launch(options) {
// TODO: remove prepare/restore process streams as soon as we roll pptr with proper fix.
prepareProcessStreams();
const userDataDir = await setupUserDataDir(options.configDir, options.doNotCopyPreferences);
const browser = await puppeteer.launch({
appMode: true,
dumpio: true,
userDataDir: await setupUserDataDir(options.configDir, options.doNotCopyPreferences),
userDataDir,
args: [
'--app=data:text/html,<style>html{background:#242424;}</style>',
'--enable-features=NetworkService',
Expand Down Expand Up @@ -63,6 +64,8 @@ async function launch(options) {
pkg = require(path.join(options.cwd, 'package.json'));
} catch (e) {
}
const preloadJs = path.join(userDataDir, 'preload.js');
await fsCopyFile(require.resolve('../node_debug_demon/preload.js'), preloadJs);
const [searchBackend, fileSystemBackend, services] = await Promise.all([
SearchBackend.create(frontend),
FileSystem.create(frontend),
Expand All @@ -75,7 +78,8 @@ async function launch(options) {
cwd: options.cwd,
serviceDir: path.join(__dirname, '..', 'services'),
repl: require.resolve('./repl.js'),
pkg: pkg
pkg: pkg,
preload: preloadJs
})};`),
frontend.evaluateOnNewDocument(`function callFrontend(f) {
${options.debugFrontend ? 'setTimeout(_ => f(), 0)' : 'f()'}
Expand Down
2 changes: 1 addition & 1 deletion services/ndd_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class NddService extends ServiceBase {

async debug({execPath, args, options}) {
const env = {
NODE_OPTIONS: `--require ${require.resolve('../node_debug_demon/preload.js')} --inspect=0`,
NODE_OPTIONS: `--require ${options.preload} --inspect=0`,
NDD_STORE: this._nddStore,
NDD_DEASYNC_JS: require.resolve('deasync'),
NDB_VERSION
Expand Down
2 changes: 1 addition & 1 deletion services/terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Terminal extends ServiceBase {
cwd: process.cwd(),
env: {
...process.env,
NODE_OPTIONS: `--require ${require.resolve('../node_debug_demon/preload.js')} --inspect=0`,
NODE_OPTIONS: `--require ${params.preload} --inspect=0`,
NDD_DEASYNC_JS: require.resolve('deasync'),
NDD_STORE: params.nddStore,
NDD_WAIT_AT_START: 1
Expand Down