mirror of
https://github.com/smogon/sprites.git
synced 2026-08-24 18:56:18 -05:00
deploy/script: move exception handling to run*
This commit is contained in:
@@ -49,12 +49,7 @@ program
|
||||
const aq = new script.ActionQueue;
|
||||
|
||||
for (const src of files) {
|
||||
try {
|
||||
script.runOnFile(scr, src, aq);
|
||||
} catch(e) {
|
||||
// Move to script.runOnFile?
|
||||
aq.throw(e);
|
||||
}
|
||||
script.runOnFile(scr, src, aq);
|
||||
}
|
||||
|
||||
runAq(aq, link, outputDir, verbose);
|
||||
@@ -69,13 +64,8 @@ program
|
||||
const aq = new script.ActionQueue;
|
||||
|
||||
for (const file of scripts) {
|
||||
try {
|
||||
const scr = new script.Script(file, 'file');
|
||||
script.run(scr, nodePath.dirname(file), aq);
|
||||
} catch(e) {
|
||||
// Move to script.run?
|
||||
aq.throw(e);
|
||||
}
|
||||
const scr = new script.Script(file, 'file');
|
||||
script.run(scr, nodePath.dirname(file), aq);
|
||||
}
|
||||
|
||||
runAq(aq, link, outputDir, verbose);
|
||||
|
||||
@@ -167,20 +167,28 @@ function makeEnv(srcDir : string, queue: ActionQueue) {
|
||||
}
|
||||
|
||||
export function runOnFile(scr : Script, src : string, queue: ActionQueue) {
|
||||
const input = pathlib.path(src, {dir: ""});
|
||||
const result = scr.runInNewContext({
|
||||
__proto__: ENV_PROTO,
|
||||
path: input,
|
||||
...input
|
||||
});
|
||||
if (result === undefined) {
|
||||
throw new Error(`undefined output on ${src}`);
|
||||
try {
|
||||
const input = pathlib.path(src, {dir: ""});
|
||||
const result = scr.runInNewContext({
|
||||
__proto__: ENV_PROTO,
|
||||
path: input,
|
||||
...input
|
||||
});
|
||||
if (result === undefined) {
|
||||
throw new Error(`undefined output on ${src}`);
|
||||
}
|
||||
const output = pathlib.update(input, result);
|
||||
const dst = pathlib.format(output);
|
||||
queue.copy(src, dst);
|
||||
} catch(e) {
|
||||
queue.throw(e);
|
||||
}
|
||||
const output = pathlib.update(input, result);
|
||||
const dst = pathlib.format(output);
|
||||
queue.copy(src, dst);
|
||||
}
|
||||
|
||||
export function run(scr : Script, srcDir : string, queue : ActionQueue) {
|
||||
scr.runInNewContext(makeEnv(srcDir, queue));
|
||||
try {
|
||||
scr.runInNewContext(makeEnv(srcDir, queue));
|
||||
} catch(e) {
|
||||
queue.throw(e);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user