Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (iOpts.completeCopy()) {
includes = ['**/*'];
} else {
includes = iOpts.extensions().map(ext => '**/*' + ext);
}
if (!input) {
return callback(new Error('No input specified'));
}
instrumenter = libInstrument.createInstrumenter(
iOpts.getInstrumenterOpts()
);
if (needBaseline) {
mkdirp.sync(path.dirname(baselineFile));
instrumenter = new BaselineCollector(instrumenter);
callback = function(err) {
/* istanbul ignore else */
if (!err) {
console.error('Saving baseline coverage at ' + baselineFile);
fs.writeFileSync(
baselineFile,
JSON.stringify(instrumenter.getCoverage()),
'utf8'
);
}
return origCallback(err);
};
}
const file = path.resolve(input);
].forEach(file => {
const content = ``;
if (!existsSync(file.from)) {
makeDir.sync(file.from);
}
writeFileSync(join(file.from, 'index.html'), content);
});
};
return count;
} else {
const filename = filenameOrDir;
const written = await handleFile(filename, path.dirname(filename));
return written ? 1 : 0;
}
}
if (!cliOptions.skipInitialBuild) {
if (cliOptions.deleteDirOnStart) {
util.deleteDir(cliOptions.outDir);
}
makeDirSync(cliOptions.outDir);
let compiledFiles = 0;
for (const filename of cliOptions.filenames) {
compiledFiles += await handle(filename);
}
if (!cliOptions.quiet) {
console.log(
`Successfully compiled ${compiledFiles} ${
compiledFiles !== 1 ? "files" : "file"
} with Babel.`,
);
}
}
if (cliOptions.watch) {
const visitor = relFile => {
const inFile = path.resolve(inputDir, relFile)
const inCode = fs.readFileSync(inFile, 'utf-8')
const outCode = this._transform(inCode, inFile) || inCode
if (output) {
const mode = fs.statSync(inFile).mode
const outFile = path.resolve(output, relFile)
mkdirp.sync(path.dirname(outFile))
fs.writeFileSync(outFile, outCode)
fs.chmodSync(outFile, mode)
} else {
console.log(outCode)
}
}
createTempDirectory () {
mkdirp.sync(this.tempDirectory())
if (this.cache) mkdirp.sync(this.cacheDirectory)
mkdirp.sync(this.processInfoDirectory())
}
function outputFileSync(filePath: string, data: string | Buffer): void {
makeDirSync(path.dirname(filePath));
fs.writeFileSync(filePath, data);
}
.then(channel => new Promise(resolve => {
const imageDir = path.join(tempDir, pkg.name);
channel.imageFile = path.join(imageDir, channel.id);
if (!fs.existsSync(channel.imageFile)) {
makeDir.sync(imageDir);
got.stream(channel.image).pipe(fs.createWriteStream(channel.imageFile));
}
resolve(channel);
}));
}
function writeDirectory(answers) {
var _path = path.join(answers.path);
var _pathData = path.join(_path, '/rest');
makeDir.sync(_path);
makeDir.sync(_pathData);
log('Wrote directory "' + _path + '"');
log('Wrore directory "' + _pathData + '"');
return Boolean(utils.existDir(_path) && utils.existDir(_pathData)) ? _path : undefined;
}
constructor(opts = {}) {
super();
const tmpDir = opts.tmpdir || os.tmpdir();
this.counter = 0;
this.mappings = [];
this.basePath = path.resolve(tmpDir, '.istanbul', 'cache_');
mkdirp.sync(path.dirname(this.basePath));
}
writeFile(file) {
if (file === null || file === '-') {
return new ConsoleWriter();
}
if (path.isAbsolute(file)) {
throw new Error(`Cannot write to absolute path: ${file}`);
}
file = path.resolve(this.baseDir, file);
mkdirp.sync(path.dirname(file));
return new FileContentWriter(fs.openSync(file, 'w'));
}
}