generated from linz/template-javascript-hello-world
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: create-manifest allows flatten as optional (#159)
In order to be able to not flatten by default the the target path when creating a manifest, a new argument `--flatten` had been added to the `create-manifest` command. Co-authored-by: Paul Fouquet <pfouquet@linz.govt.nz> Co-authored-by: Megan Davidson <mdavidson@linz.govt.nz>
- Loading branch information
1 parent
80b8d18
commit 76c20f6
Showing
5 changed files
with
91 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/commands/create-manifest/__test__/create-manifest.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { fsa } from '@chunkd/fs'; | ||
import { FsMemory } from '@chunkd/source-memory'; | ||
import o from 'ospec'; | ||
import { createManifest } from '../create-manifest.js'; | ||
|
||
o.spec('argoLocation', () => { | ||
o.beforeEach(() => { | ||
memory.files.clear(); | ||
}); | ||
const memory = new FsMemory(); | ||
fsa.register('memory://', memory); | ||
o.only('should copy to the target location', async () => { | ||
await Promise.all([ | ||
fsa.write('memory://source/topographic.json', Buffer.from(JSON.stringify({ test: true }))), | ||
fsa.write('memory://source/foo/bar/topographic.png', Buffer.from('test')), | ||
]); | ||
|
||
const outputFiles = await createManifest('memory://source/', 'memory://target/', { flatten: true }); | ||
o(outputFiles[0]).deepEquals([ | ||
{ | ||
source: 'memory://source/topographic.json', | ||
target: 'memory://target/topographic.json', | ||
}, | ||
{ | ||
source: 'memory://source/foo/bar/topographic.png', | ||
target: 'memory://target/topographic.png', | ||
}, | ||
]); | ||
}); | ||
|
||
o.only('should copy to the target location without flattening', async () => { | ||
await Promise.all([ | ||
fsa.write('memory://source/topographic.json', Buffer.from(JSON.stringify({ test: true }))), | ||
fsa.write('memory://source/foo/bar/topographic.png', Buffer.from('test')), | ||
]); | ||
|
||
const outputFiles = await createManifest('memory://source/', 'memory://target/sub/', { flatten: false }); | ||
o(outputFiles[0]).deepEquals([ | ||
{ | ||
source: 'memory://source/topographic.json', | ||
target: 'memory://target/sub/topographic.json', | ||
}, | ||
{ | ||
source: 'memory://source/foo/bar/topographic.png', | ||
target: 'memory://target/sub/foo/bar/topographic.png', | ||
}, | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters