deploy/script: factor out more cli logic into runOnFile

This commit is contained in:
Christopher Monsanto
2020-08-08 04:41:13 -04:00
parent e33c041f79
commit 24edce9b94
3 changed files with 17 additions and 19 deletions

View File

@@ -64,8 +64,18 @@ export class Script {
this.script = new vm.Script(code);
}
runOnFile(p : pathlib.Path) : any {
return this.script.runInNewContext({spritename: _spritename, path: p, ...p});
runOnFile(src : pathlib.Path) : pathlib.Path {
const input = pathlib.update(src, {dir: ""});
const result = this.script.runInNewContext({
spritename: _spritename,
path: input,
...input
});
if (result === undefined) {
throw new Error(`undefined output on ${pathlib.format(src)}`);
}
const output = pathlib.path(input, result);
return output;
}
run(srcDir : string, dstDir : string, queue : ActionQueue) {