mirror of
https://github.com/smogon/sprites.git
synced 2026-08-20 00:34:22 -05:00
deploy/script: copy() takes delta
This commit is contained in:
@@ -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"},
|
||||
]));
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user