mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
PR-URL: https://github.com/nodejs/node/pull/59775 Reviewed-By: Dario Piotrowicz <dario.piotrowicz@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
25 lines
900 B
JavaScript
25 lines
900 B
JavaScript
// This tests that cpSync throws error if attempt is made to copy directory to file.
|
|
import { isInsideDirWithUnusualChars, mustNotMutateObjectDeep, skip } from '../common/index.mjs';
|
|
import { nextdir } from '../common/fs.js';
|
|
import assert from 'node:assert';
|
|
import { cpSync, mkdirSync } from 'node:fs';
|
|
import tmpdir from '../common/tmpdir.js';
|
|
import fixtures from '../common/fixtures.js';
|
|
|
|
// See https://github.com/nodejs/node/pull/48409
|
|
if (isInsideDirWithUnusualChars) {
|
|
skip('Test is borken in directories with unusual characters');
|
|
}
|
|
|
|
tmpdir.refresh();
|
|
|
|
{
|
|
const src = nextdir('FIRST_DIRECTORY');
|
|
mkdirSync(src, mustNotMutateObjectDeep({ recursive: true }));
|
|
const dest = fixtures.path('copy/kitchen-sink/README.md');
|
|
assert.throws(
|
|
() => cpSync(src, dest),
|
|
{ code: 'ERR_FS_CP_DIR_TO_NON_DIR', message: /non-directory .*README\.md with directory .*FIRST_DIRECTORY/ }
|
|
);
|
|
}
|