1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-30 08:26:59 +02:00
joplin/CliClient/app/main_launcher.js
2017-07-09 16:47:05 +01:00

32 lines
939 B
JavaScript

#!/usr/bin/env node
// Because all the files in the "lib" directory are included as "lib/file.js" it
// means "lib" must be in NODE_PATH, however modifying the global NODE_PATH
// variable would be messy. So instead, the path is set temporarily just before running
// the app. To do this, this wrapper is needed.
// See https://gist.github.com/branneman/8048520
// Original wrapper code from https://gist.github.com/branneman/8775568
'use strict';
var spawn = require('child_process').spawn;
var args = ['main.js'];
var processArgs = process.argv.splice(2);
args = args.concat(processArgs);
var opt = {
cwd: __dirname,
env: (function() {
process.env.NODE_PATH = '.'; // Enables require() calls relative to the cwd :)
return process.env;
}()),
stdio: [process.stdin, process.stdout, process.stderr]
};
var app = spawn(process.execPath, args, opt);
// Pass on the exit code
app.on('close', (code) => {
process.exit(code);
});