Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function promptUntilValidKeyPath(
cerr: typeof console.error,
): Promise {
const { privateKeyPath } = await inquirer.prompt([
{
type: 'input',
name: 'privateKeyPath',
message: 'Path to private key file',
// TODO: Move the fileExists validation logic to this object under the validate key to fail earlier
},
]);
if (
!(await fileExists(
// Expand tilde characters in paths
untildify(privateKeyPath),
))
) {
printErrors(cerr, { message: 'File does not exist at given path!' });
return promptUntilValidKeyPath(cerr);
}
return privateKeyPath;
}
sclangConfigOptions(options: SCLangOptions): SCLangConf {
const runtimeIncludePaths = [path.resolve(__dirname, "./supercollider-js")];
const defaultConf: SCLangConf = {
postInlineWarnings: false,
includePaths: [],
excludePaths: [],
};
let conf = defaultConf;
if (options.sclang_conf) {
try {
conf = yaml.safeLoad(fs.readFileSync(untildify(options.sclang_conf), "utf8"));
} catch (e) {
// By default allow a missing sclang_conf file
// so that the language can create it on demand if you use Quarks or LanguageConfig.
if (!options.failIfSclangConfIsMissing) {
// Was the sclang_conf just in the defaults or was it explicitly set ?
this.log.dbug(e);
conf = defaultConf;
} else {
throw new Error("Cannot open or read specified sclang_conf " + options.sclang_conf);
}
}
}
return {
includePaths: _.union(conf.includePaths, options.conf.includePaths, runtimeIncludePaths),
excludePaths: _.union(conf.excludePaths, options.conf.excludePaths),
addDir (message) {
fs.mkdirs(untildify(message.destinationpath), (err) => {
if (err) return this.emit(fsEvents.ADD_DIR_ERROR, err);
this.emit(fsEvents.ADD_DIR, message.destinationpath);
});
}
function getPreludePath() {
let preludePath = atom.config.get('elmjutsu.evalPreludePath');
if (!preludePath || preludePath.trim() === '') {
preludePath = path.join(
path.dirname(atom.config.getUserConfigPath()),
'packages',
'elmjutsu',
'elm',
'EvalPrelude.elm'
);
}
return untildify(preludePath);
}
argv.coerce('localFilePath', p => untildify(p)).epilog(epilog(exports))
handler: argv => {
const files = argv.files.map(untildify)
const roots = (argv.R || []).map(untildify)
log.silly('unpack', 'files', files)
log.silly('unpack', 'roots', roots)
commands.active = unpack(
{ files, roots, pattern: argv.P },
argv.s,
argv.archive && argv.archiveRoot && untildify(argv.archiveRoot),
argv.playlist && untildify(argv.playlist)
)
}
}
.coerce('outDir', p => untildify(p))
.epilog(epilog(exports))
HTMLReporter.prototype.sanitizedPath = function sanitizedPath(
path = './report.html',
) {
const filePath = pathmodule.resolve(untildify(path));
if (fs.existsSync(filePath)) {
logger.warn(`File exists at ${filePath}, will be overwritten...`);
}
return filePath;
};
const _produceAbsolutePath = filePath => {
const untildified = untildify(filePath.trim());
return !path.isAbsolute(untildified) ? path.resolve(untildified) : untildified;
};
public directoryExists(path: string): boolean {
return existsSync(untildify(path));
}