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() })
async function generate(args, options) { const pageres = new Pageres({ incrementalName: !options.overwrite }).dest(process.cwd()); for (const argument of args) { pageres.src(argument.url, argument.sizes, argument.options); } await pageres.run(); pageres.successMessage(); }
location (depth) { depth = depth || 0; let loc = process.cwd(); let pathnames = loc.split(path.sep); // If Window directory drive, don't add starting "/" let fullpath = pathnames[0].indexOf(':') > -1 ? path.join.apply(path, pathnames.slice(0, pathnames.length - depth)) : path.join.apply(path, ['/'].concat(pathnames.slice(0, pathnames.length - depth))); return this.workspace() && depth <= pathnames.length && fullpath.toLowerCase() === this.workspace().toLowerCase(); }
/**************** START : files related ****************/ downloadFile(req, res) { let file = path.join(process.cwd(), req.query.name); res.download(file); }
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); } }); }
// returns promise that passes db obj function init() { const dbname = conf.comments || conf; const dbpath = path.resolve(process.cwd(), dbname); return Promise.resolve(db.open(dbpath, { Promise })) .then(db => db.migrate({ // force: process.env.NODE_ENV === 'development' ? 'last' : false force: false }) ) .then(db => db.driver) // @FIXME .catch(err => console.error(err)); }
// Middleware to catch 404 errors app.use(function(req, res, next) { res.status(404).sendFile(process.cwd() + '/app/views/404.htm'); });
function writeFile(directory, pathname, buffer, dirs) { pathname = path.join.apply(path, [].concat(directory.split('/'), pathname.split('/'))); let paths = pathname.split(path.sep); for (let i = 1; i < paths.length; i++) { let dirpath = path.join.apply(path, [process.cwd()].concat(paths.slice(0, i))); if (!dirs[dirpath]) { !fs.existsSync(dirpath) && fs.mkdirSync(dirpath); dirs[dirpath] = true; } } fs.writeFileSync(path.join(process.cwd(), pathname), buffer, {mode: 0o777}); return dirs; }
constructor(frontend, pty, env, cols, rows) { require('../lib/process_utility.js')('terminal', () => this.dispose()); let shell = process.env.SHELL; if (!shell || !fs.existsSync(shell)) shell = process.platform === 'win32' ? 'cmd.exe' : 'bash'; this._term = pty.spawn(shell, [], { name: 'xterm-color', cols: cols, rows: rows, cwd: process.cwd(), env: { ...process.env, ...env } }); this._term.on('data', data => frontend.dataAdded(data)); this._term.on('close', () => frontend.closed()); }
async function main() { const argv = require('yargs').argv; process.chdir(appDir); console.info(`Running from: ${process.cwd()}`); const version = (await execCommand('npm version patch')).trim(); const tagName = version; console.info(`New version number: ${version}`); console.info(await execCommand('git add -A')); console.info(await execCommand(`git commit -m "Electron release ${version}"`)); console.info(await execCommand(`git tag ${tagName}`)); console.info(await execCommand('git push && git push --tags')); const releaseOptions = { isDraft: true, isPreRelease: !!argv.beta }; console.info('Release options: ', releaseOptions); const release = await githubRelease('joplin', tagName, releaseOptions); console.info(`Created GitHub release: ${release.html_url}`); console.info('GitHub release page: https://github.com/laurent22/joplin/releases'); console.info(`To create changelog: node Tools/git-changelog.js ${version}`); }
legacypath () { let cwd = process.cwd(); let directories = cwd.split(path.sep); let pathname; for (let i = directories.length; i > 0; i--) { let relpath = path.join(directories.slice(0, i).join(path.sep), LEGACY_FILENAME); if (fs.existsSync(relpath)) { pathname = relpath; break; } } return pathname; }
constructor(args, mysqlPool, app) { this.config = args; this.mysql = new Xsql(args, mysqlPool); this.app = app; this.ctrls = []; /**************** START : multer ****************/ this.storage = multer.diskStorage({ destination: function(req, file, cb) { cb(null, process.cwd()); }, filename: function(req, file, cb) { console.log(file); cb(null, Date.now() + "-" + file.originalname); } }); this.upload = multer({ storage: this.storage }); /**************** END : multer ****************/ }
gulp.task('build-tests', () => { const folder = 'test'; const testFile = 'all.html'; try { fs.unlinkSync(`${folder}/${testFile}`); } catch (e) {} const rootPath = path.resolve(process.cwd(), folder); const warning = '<!-- the following list of javascript files is built automatically -->\n'; const files = readDirDeepSync(rootPath, { patterns: [ '**/*.js' ], ignore: [ '*.js' ] }) .map(file => file.replace(/^test\//, '')); return gulp.src(`${folder}/all-template.html`) .pipe(replace('{{test-files}}', warning + files.map(file => `<script type="module" src="${file}"></script>`).join('\n'))) .pipe(rename(testFile)) .pipe(gulp.dest(folder)); });
function findPath (maxDepth) { maxDepth = parseInt(maxDepth) || 0; let cwd = process.cwd(); let directories = cwd.split(path.sep); let stdlibPath = ''; for (let i = directories.length; i > 0; i--) { let relpath = path.join(directories.slice(0, i).join(path.sep), FILENAME); if (fs.existsSync(relpath)) { stdlibPath = relpath; break; } if (!(--maxDepth)) { break; } } return stdlibPath; }
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() })