mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-28 01:38:03 +08:00
Add option to cp to only copy contents of directory (#788)
* Add option to not copy source directory * Cleanup * Update condition to be consistent
This commit is contained in:
@@ -90,6 +90,29 @@ describe('cp', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('copies directory into existing destination with -r without copying source directory', async () => {
|
||||
const root: string = path.join(
|
||||
getTestTemp(),
|
||||
'cp_with_-r_existing_dest_no_source_dir'
|
||||
)
|
||||
const sourceFolder: string = path.join(root, 'cp_source')
|
||||
const sourceFile: string = path.join(sourceFolder, 'cp_source_file')
|
||||
|
||||
const targetFolder: string = path.join(root, 'cp_target')
|
||||
const targetFile: string = path.join(targetFolder, 'cp_source_file')
|
||||
await io.mkdirP(sourceFolder)
|
||||
await fs.writeFile(sourceFile, 'test file content', {encoding: 'utf8'})
|
||||
await io.mkdirP(targetFolder)
|
||||
await io.cp(sourceFolder, targetFolder, {
|
||||
recursive: true,
|
||||
copySourceDirectory: false
|
||||
})
|
||||
|
||||
expect(await fs.readFile(targetFile, {encoding: 'utf8'})).toBe(
|
||||
'test file content'
|
||||
)
|
||||
})
|
||||
|
||||
it('copies directory into non-existing destination with -r', async () => {
|
||||
const root: string = path.join(getTestTemp(), 'cp_with_-r_nonexistent_dest')
|
||||
const sourceFolder: string = path.join(root, 'cp_source')
|
||||
|
||||
Reference in New Issue
Block a user