fix: Rename copyDirectory util to copyFileOrDirectory.

This commit is contained in:
Sam 2023-01-16 15:04:08 +02:00
parent 6c5e35f68d
commit b7d38844c8
No known key found for this signature in database
GPG Key ID: D004126FCD1A6DF0
4 changed files with 25 additions and 9 deletions

1
.gitignore vendored
View File

@ -25,6 +25,7 @@ packages/plugins/connections/connection-mongodb/*.lock
packages/utils/node-utils/test/writeFile/writeFile.txt
packages/utils/node-utils/test/copyDirectory/**
packages/utils/node-utils/test/copyFile/**
app/**
packages/server-dev/plugins/**

View File

@ -16,8 +16,8 @@
import fsExtra from 'fs-extra';
async function copyDirectory(dirPathFrom, dirPathTo, options) {
async function copyFileOrDirectory(dirPathFrom, dirPathTo, options) {
await fsExtra.copy(dirPathFrom, dirPathTo, options);
}
export default copyDirectory;
export default copyFileOrDirectory;

View File

@ -16,11 +16,11 @@
import fs from 'fs-extra';
import path from 'path';
import copyDirectory from './copyDirectory.js';
import copyFileOrDirectory from './copyFileOrDirectory.js';
test('copyDirectory', async () => {
const dirPathFrom = path.resolve(process.cwd(), 'test/copyDirectory/From/');
const dirPathTo = path.resolve(process.cwd(), 'test/copyDirectory/To/');
test('copy directory', async () => {
const dirPathFrom = path.resolve(process.cwd(), 'test/copyDirectory/from/');
const dirPathTo = path.resolve(process.cwd(), 'test/copyDirectory/to/');
const filePathFrom = path.resolve(dirPathFrom, 'copyDirectory.txt');
const filePathTo = path.resolve(dirPathTo, 'copyDirectory.txt');
@ -29,6 +29,21 @@ test('copyDirectory', async () => {
});
fs.writeFileSync(filePathFrom, 'copyDirectory');
await copyDirectory(dirPathFrom, dirPathTo);
await copyFileOrDirectory(dirPathFrom, dirPathTo);
expect(fs.existsSync(filePathTo)).toBe(true);
});
test('copy file', async () => {
const dirPathFrom = path.resolve(process.cwd(), 'test/copyFile/from/');
const dirPathTo = path.resolve(process.cwd(), 'test/copyFile/to/');
const filePathFrom = path.resolve(dirPathFrom, 'copyFile.txt');
const filePathTo = path.resolve(dirPathTo, 'copyFile.txt');
fs.mkdirSync(dirPathFrom, {
recursive: true,
});
fs.writeFileSync(filePathFrom, 'copyFile');
await copyFileOrDirectory(filePathFrom, filePathTo);
expect(fs.existsSync(filePathTo)).toBe(true);
});

View File

@ -15,7 +15,7 @@
*/
import cleanDirectory from './cleanDirectory.js';
import copyDirectory from './copyDirectory.js';
import copyFileOrDirectory from './copyFileOrDirectory.js';
import getConfigFromEnv from './getConfigFromEnv.js';
import getFileExtension, { getFileSubExtension } from './getFileExtension.js';
import getSecretsFromEnv from './getSecretsFromEnv.js';
@ -25,7 +25,7 @@ import writeFile from './writeFile.js';
export {
cleanDirectory,
copyDirectory,
copyFileOrDirectory,
getConfigFromEnv,
getFileExtension,
getFileSubExtension,