mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-03-19 15:01:06 +08:00
feat(node-utils): Add copyDirectory.
This commit is contained in:
parent
e15031d32d
commit
852a77a627
3
.gitignore
vendored
3
.gitignore
vendored
@ -27,3 +27,6 @@ packages/build/build/**
|
||||
packages/plugins/connections/connection-mongodb/mongod-*
|
||||
packages/plugins/connections/connection-mongodb/globalConfig.json
|
||||
packages/plugins/connections/connection-mongodb/*.lock
|
||||
|
||||
packages/utils/node-utils/test/writeFile/writeFile.txt
|
||||
packages/utils/node-utils/test/copyDirectory/**
|
||||
|
23
packages/utils/node-utils/src/copyDirectory.js
Normal file
23
packages/utils/node-utils/src/copyDirectory.js
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
Copyright 2020-2021 Lowdefy, Inc
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import fsExtra from 'fs-extra';
|
||||
|
||||
async function copyDirectory(dirPathFrom, dirPathTo) {
|
||||
await fsExtra.copy(dirPathFrom, dirPathTo);
|
||||
}
|
||||
|
||||
export default copyDirectory;
|
34
packages/utils/node-utils/src/copyDirectory.test.js
Normal file
34
packages/utils/node-utils/src/copyDirectory.test.js
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 2020-2021 Lowdefy, Inc
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
import copyDirectory from './copyDirectory.js';
|
||||
|
||||
test('copyDirectory', 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');
|
||||
|
||||
fs.mkdirSync(dirPathFrom, {
|
||||
recursive: true,
|
||||
});
|
||||
fs.writeFileSync(filePathFrom, 'copyDirectory');
|
||||
|
||||
await copyDirectory(dirPathFrom, dirPathTo);
|
||||
expect(fs.existsSync(filePathTo)).toBe(true);
|
||||
});
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import cleanDirectory from './cleanDirectory.js';
|
||||
import copyDirectory from './copyDirectory.js';
|
||||
import getConfigFromEnv from './getConfigFromEnv.js';
|
||||
import getFileExtension, { getFileSubExtension } from './getFileExtension.js';
|
||||
import getSecretsFromEnv from './getSecretsFromEnv.js';
|
||||
@ -24,6 +25,7 @@ import writeFile from './writeFile.js';
|
||||
|
||||
export {
|
||||
cleanDirectory,
|
||||
copyDirectory,
|
||||
getConfigFromEnv,
|
||||
getFileExtension,
|
||||
getFileSubExtension,
|
||||
|
Loading…
x
Reference in New Issue
Block a user