lstat panicks if file doesnt exist

This commit is contained in:
2022-06-08 10:09:14 -05:00
parent 588ee08d10
commit f0c3f7db1a
6 changed files with 14 additions and 9 deletions

View File

@@ -36,7 +36,7 @@ async function compileProject(name) {
error = e.message;
}
//add UserScript header
if ((0, fs_1.lstatSync)(outPath).isFile()) {
if ((0, fs_1.existsSync)(outPath)) {
if (!error) {
let content = (0, fs_1.readFileSync)(outPath).toString();
(0, fs_1.writeFileSync)(outPath, metaString + content);
@@ -47,7 +47,7 @@ async function compileProject(name) {
}
return [metaJson, error];
}
if (!(0, fs_1.lstatSync)('package.json').isFile()) {
if (!(0, fs_1.existsSync)('package.json') || !(0, fs_1.lstatSync)('package.json').isFile()) {
console.error('package.json not found, unwilling to run');
process.exit(1);
}
@@ -62,7 +62,9 @@ if (!(0, fs_1.lstatSync)('package.json').isFile()) {
for (let name of scripts) {
let path = (0, paths_1.ScriptPath)(name);
if (!name.endsWith('_') &&
(0, fs_1.existsSync)(path.dir) &&
(0, fs_1.lstatSync)(path.dir).isDirectory() &&
(0, fs_1.existsSync)(path.main) &&
(0, fs_1.lstatSync)(path.main).isFile()) {
let [meta, error] = await compileProject(name);
scriptMeta.push({