deploy/script: copy() takes delta

This commit is contained in:
Christopher Monsanto
2020-08-13 02:11:12 -04:00
parent 5033364925
commit 5cb88c94d2
2 changed files with 21 additions and 4 deletions

View File

@@ -27,3 +27,15 @@ test('run identity', () => {
]));
});
test('run delta', () => {
const aq = new script.ActionQueue();
const scr = new script.Script(` list(".").forEach(p => copy(p, {dir: "dest"}))`, 'expr');
script.run(scr, "testsrc", aq);
expect(aq.describe(".")).toEqual(expect.arrayContaining([
{src: 'testsrc/32.png', dst: "dest/32.png"},
{src: 'testsrc/192-g-vsmogon.png', dst: "dest/192-g-vsmogon.png"},
]));
});

View File

@@ -85,10 +85,15 @@ function makeEnv(srcDir : string, queue: ActionQueue) {
return result;
},
copy(src : pathlib.PathLike, dst : pathlib.PathLike) {
const srcp = pathlib.path(src);
const dstp = pathlib.path(dst);
queue.copy(pathlib.format(pathlib.join(srcDir, srcp)), pathlib.format(dstp));
copy(srcp : pathlib.PathLike, dstp : string | pathlib.Delta /* todo deltalike */) {
const src = pathlib.format(pathlib.path(srcp));
let dst : string;
if (typeof dstp === 'string') {
dst = dstp;
} else {
dst = pathlib.format(pathlib.path(srcp, dstp));
}
queue.copy(nodePath.join(srcDir, src), dst);
}
}
}