(process.env.NODE_PATH || '') .split(path.delimiter) .filter(folder => folder && !path.isAbsolute(folder)) .map(folder => path.resolve(appDirectory, folder)) .join(path.delimiter)
// Makes the script crash on unhandled rejections instead of silently // ignoring them. In the future, promise rejections that are not handled will // terminate the Node.js process with a non-zero exit code. process.on('unhandledRejection', err => { throw err; });
function exitWithErrorMessage(message: string): never { console.error(message); console.error(); console.error('For help, run `postgraphile --help`'); process.exit(1); }
updateDisks() { if (!PLATFORMS_SUPPORTED.includes(process.platform)) { return Promise.resolve([]); } return diskUsage[process.platform]().then(disks => { if (disks.length !== this.disks.length || disks.some((d, i) => d.used !== this.disks[i].used)) { this.tLastChange = Date.now(); this.disks = disks; this.emit(diskUsageServiceEvents.DISK_USAGE_CHANGE, this.getDiskUsage()); } }); }
// Helper to determine whether we should exclude const shouldExclude = (excludes = []) => { // Only do this on non linux if (process.platform === 'linux') return false; // Otherwise return if we have non-empty config return !_.isEmpty(getExcludes(excludes)); }
test('error.signal is SIGINT', async t => { const subprocess = execa('noop'); process.kill(subprocess.pid, 'SIGINT'); const {signal} = await t.throwsAsync(subprocess, {message: /was killed with SIGINT/}); t.is(signal, 'SIGINT'); });
_(process.env) // Only muck with prefix_ variables .pickBy((value, key) => _.includes(key, prefix)) // Prep the keys for consumption .mapKeys((value, key) => _.camelCase(_.trimStart(key, prefix))) // If we have a JSON string as a value, parse that and assign its sub-keys .mapValues(exports.tryConvertJson) // Resolve the lodash wrapper .value()
test('node correctly use nodePath', async t => { const {stdout} = await execa.node(process.platform === 'win32' ? 'hello.cmd' : 'hello.sh', { stdout: 'pipe', nodePath: process.platform === 'win32' ? 'cmd.exe' : 'bash', nodeOptions: process.platform === 'win32' ? ['/c'] : [] }); t.is(stdout, 'Hello World'); });
// Makes the script crash on unhandled rejections instead of silently // ignoring them. In the future, promise rejections that are not handled will // terminate the Node.js process with a non-zero exit code. process.on('unhandledRejection', err => { throw err; });
// Makes the script crash on unhandled rejections instead of silently // ignoring them. In the future, promise rejections that are not handled will // terminate the Node.js process with a non-zero exit code. process.on('unhandledRejection', err => { throw err; });
// Makes the script crash on unhandled rejections instead of silently // ignoring them. In the future, promise rejections that are not handled will // terminate the Node.js process with a non-zero exit code. process.on('unhandledRejection', err => { throw err; });
test('error.signalDescription is defined', async t => { const subprocess = execa('noop'); process.kill(subprocess.pid, 'SIGINT'); const {signalDescription} = await t.throwsAsync(subprocess, {message: /User interruption with CTRL-C/}); t.is(signalDescription, 'User interruption with CTRL-C'); });
test('error.signal is SIGTERM', async t => { const subprocess = execa('noop'); process.kill(subprocess.pid, 'SIGTERM'); const {signal} = await t.throwsAsync(subprocess, {message: /was killed with SIGTERM/}); t.is(signal, 'SIGTERM'); });