fetchContext: () => Promise.resolve({}), fetchTemplate: fetchTemplate( templatesPath || path.join(process.cwd(), 'templates') ), fragmentTag: 'fragment',
describe('parseVolumes', () => { it('returns volumes with correct pathing', () => { expect(command.parseVolumes([ './foo:/bar', '/foo:/bar' ])).to.deep.equal([ `${process.cwd()}/foo:/bar`, '/foo:/bar' ]) }) })
vols.map((v) => v.startsWith('.') ? path.resolve(process.cwd(), v) : v)
/** * Initializes a project by creating a binci.yml config */ const init = () => input.text('Enter base docker image to use, or press enter to build ./Dockerfile: ') .catch(() => { throw new Error('Could not read input') }) .then((answer) => { const line = answer ? `from: ${answer}` : 'dockerfile: ./Dockerfile' return fs.writeFileAsync(`${process.cwd()}/binci.yml`, configTemplate(line)) .then(() => 'Config file created') .catch(() => { throw new Error('Unable to write config file') }) })
describe('getHash', () => { it('determines the SHA-1 hash of an existing file', () => { return images.getHash([knownShaPath]).then(hash => { expect(hash).to.equal(knownSha.substr(0, 12)) }) }) it('determines the SHA-1 hash of multiple files', () => { return images.getHash([knownShaPath, knownShaPath]).then(hash => { expect(hash).to.equal('cdb39cef22e6') }) }) it('returns null if the file does not exist', () => { return images.getHash([knownShaPath + 'notfound']).then(hash => { expect(hash).to.be.null() }) }) it('fails on file read errors', () => { return expect(images.getHash(process.cwd())).to.be.rejected() }) })
try { fs.statSync(`${process.cwd()}/binci.yml`) } catch (e) { return args.init()
return args.parse().then(() => { expect(args.init).to.be.calledOnce() process.cwd.restore() }) })
}) afterEach((done) => { process.cwd.restore() rimraf(`${__dirname}/tmp`, done) })
describe('parseArgs', () => { it('returns an array of a specific argument type and its values', () => { expect(command.parseArgs('expose', ['8080:8080', '9090:9090'])).to.deep.equal(['-p', '8080:8080', '-p', '9090:9090']) expect(command.parseArgs('volumes', [ './foo:/bar' ])).to.deep.equal(['-v', `${process.cwd()}/foo:/bar`]) }) })
/** * ResolvePath - Resolve path from cwd * * @export * @param {Clipped} this * @param {...string[]} dirs * @returns {string} */ export function resolvePath(this: Clipped, ...dirs: string[]): string { return path.join((this && this.config && this.config.context) || process.cwd(), ...dirs) }
const delete_temp_images = (req, res, next) => { pi.DeleteAllOfFolder(process.cwd()+'/public/temp/') next() }
const loadTypeSchema = type => new Promise((resolve, reject) => { const pathToSchema = path.join( process.cwd(), `src/types/${type}/${type}.gql` ) fs.readFile(pathToSchema, { encoding: 'utf-8' }, (err, schema) => { if (err) { return reject(err) } resolve(schema) }) })
program .command('dirname') .action(() => { console.log('DIRNAME: ', __dirname); console.log('FILENAME: ', __filename); console.log('PROCESS: ', process.cwd()); const isRoot = readFileSync(path.resolve(PROJECTDIR, 'package.json')); try { readdirSync(path.resolve(PROJECTDIR, 'build')); } catch(err) { message('error', 'Plese run in root of the project after build all files'); throw new Error(err); } if(!isRoot) { message('error', 'Plese run in root of the project after build all files'); throw new Error(err); } });
it('when invoking with debug command, it should produce full args', () => { const argv = ['node', 'monopack.js', 'debug', 'main.js']; const { exit, errors, logs, warnings, result } = checkOutput( args => getArgs(args), argv ); expect(exit).toBe(null); expect(errors).toEqual([]); expect(logs).toEqual([]); expect(warnings).toEqual([]); expect(result.command).toBe('debug'); expect(result.currentWorkingDirectory).toBe(process.cwd()); expect(result.debugOptions).toEqual({}); expect(result.extraModules).toEqual([]); expect(result.installPackages).toEqual(null); expect(result.mainJs).toEqual('main.js'); expect(result.nodeArgs).toEqual([]); expect(result.outputDirectory).toEqual(null); expect(result.runArgs).toEqual([]); expect(result.watch).toEqual(false); });