test('getSocketPath', () => { const socketPath = awsServerlessExpress.getSocketPath('12345abcdef') const isWin = process.platform === 'win32' const expectedSocketPath = isWin ? path.join('\\\\?\\\\pipe\\\\', process.cwd(), 'server-12345abcdef') : '/tmp/server-12345abcdef.sock' expect(socketPath).toBe(expectedSocketPath) })
function addDebugPaths(plugins) { if (config.debugMode) { plugins.unshift(process.cwd()); } }
initSourceDirectory() { if (this.program.sourceDirectory) { this.envConfig.sourceDirectory = this.program.sourceDirectory; } else { this.envConfig.sourceDirectory = process.cwd(); } }
/**************** START : files related ****************/ downloadFile(req, res) { let file = path.join(process.cwd(), req.query.name); res.download(file); }
async debug(execPath, args, options) { options = options || {}; const debugId = options.data || String(++this._lastDebugId); if (!options.data) this._lastStarted = {execPath, args, debugId, isProfiling: !!this._finishProfiling}; return this._service.debug( execPath, args, { ...options, data: debugId, cwd: Ndb.processInfo.cwd }); }
pkg() { // TODO(ak239spb): implement it as decorations over package.json file. try { return require(path.join(fileURLToPath(this._info.cwd), 'package.json')); } catch (e) { return null; } }
process.on('uncaughtException', function(err){ if (!err || err.code !== 'ERR_IPC_CHANNEL_CLOSED') { var stack = util.getErrorStack(err); fs.writeFileSync(path.join(process.cwd(), config.name + '.log'), '\r\n' + stack + '\r\n', {flag: 'a'}); /*eslint no-console: "off"*/ console.error(stack); } process.exit(1); });
runner(process.argv.slice(2), { templates: defaultTemplates, cwd: process.cwd(), logger: new Logger(console.log.bind(console)), debug: !!process.env.DEBUG, exec: (action, body) => { const opts = body && body.length > 0 ? { input: body } : {} return require('execa').command(action, { ...opts, shell: true }) }, createPrompter: () => require('enquirer'), }).then(({ success }) => process.exit(success ? 0 : 1))
function hotReloadService(service) { const relPath = path.relative(process.cwd(), service.__filename); broker.logger.info(`Hot reload '${service.name}' service...`, kleur.grey(relPath)); return broker.destroyService(service) .then(() => { if (fs.existsSync(service.__filename)) { return broker.loadService(service.__filename); } }); }
test("Taskr.constructor (defaults)", t => { const taskr = new Taskr() t.true(taskr instanceof Taskr, "returns a Taskr class") t.equal(taskr.file, undefined, "`taskr.file` is `undefined`") t.equal(taskr.root, process.cwd(), "`taskr.root` is `process.cwd()`") t.true($.isEmptyObj(taskr.tasks), "`taskr.tasks` is an empty object") t.true($.isEmptyObj(taskr.plugins), "`taskr.plugins` is an empty object") t.true(Array.isArray(taskr.plugNames), "`taskr.plugNames` is an array") t.true(taskr.plugNames.length === 0, "`taskr.plugNames` is empty") t.end() })
const getSourceFilePaths = () => { return new Promise((resolve, reject) => { glob(SOURCE_PATTERN, (error, files) => { if (error) { reject(error); return; } resolve(files.map(filePath => path.join(process.cwd(), filePath))); }); }); }
constructor (options) { super() if (typeof options === 'string' || Array.isArray(options)) { options = { cmd: options } } this.cmd = options.cmd this.cwd = path.resolve(options.cwd || '.') this.wait = options.wait || 1e3 this.port = null this[kProcess] = null }
function getTestRoot(currentPath) { if (!currentPath) currentPath = '.'; if (!path.isAbsolute(currentPath)) currentPath = path.join(process.cwd(), currentPath); currentPath = fs.lstatSync(currentPath).isDirectory() || !path.extname(currentPath) ? currentPath : path.dirname(currentPath); return currentPath; }
function getAbsolutePath(relative) { if (path.isAbsolute(relative)) { return relative; } return path.normalize(path.join(process.cwd(), relative)); }
function getSocketPath (socketPathSuffix) { /* istanbul ignore if */ /* only running tests on Linux; Window support is for local dev only */ if (/^win/.test(process.platform)) { const path = require('path') return path.join('\\\\?\\pipe', process.cwd(), `server-${socketPathSuffix}`) } else { return `/tmp/server-${socketPathSuffix}.sock` } }