@goldstack/utils-sh
Advanced tools
Comparing version
@@ -44,3 +44,3 @@ "use strict"; | ||
for (const sourceEl of sourceArr) { | ||
const files = glob_1.sync(sourceEl); | ||
const files = (0, glob_1.sync)(sourceEl); | ||
for (let i = 0; i < files.length; i++) { | ||
@@ -56,3 +56,3 @@ const file = files[i]; | ||
} | ||
ncp_1.default(file, destCorrected, { stopOnErr: true }, (err) => { | ||
(0, ncp_1.default)(file, destCorrected, { stopOnErr: true }, (err) => { | ||
if (err) { | ||
@@ -84,3 +84,3 @@ reject(err); | ||
await new Promise((resolve, reject) => { | ||
rimraf_1.default(file, { | ||
(0, rimraf_1.default)(file, { | ||
maxBusyTries: 10, | ||
@@ -121,3 +121,3 @@ }, (e) => { | ||
const output = fs_1.default.createWriteStream(params.target); | ||
const archive = archiver_1.default('zip', { | ||
const archive = (0, archiver_1.default)('zip', { | ||
zlib: { level: 9 }, | ||
@@ -143,3 +143,3 @@ }); | ||
const unzip = async (params) => { | ||
await extract_zip_1.default(params.file, { | ||
await (0, extract_zip_1.default)(params.file, { | ||
dir: path_1.default.resolve(params.targetDirectory), | ||
@@ -146,0 +146,0 @@ }); |
@@ -11,30 +11,30 @@ "use strict"; | ||
beforeAll(async () => { | ||
await utilsSh_1.rmSafe('./work'); | ||
utilsSh_1.mkdir('-p', './work'); | ||
await (0, utilsSh_1.rmSafe)('./work'); | ||
(0, utilsSh_1.mkdir)('-p', './work'); | ||
}); | ||
it('Should copy all files (including hidden)', async () => { | ||
const testDir = './goldstackLocal/work/copyAll/'; | ||
utilsSh_1.mkdir('-p', testDir); | ||
utilsSh_1.write('dummy', testDir + '.hidden'); | ||
utilsSh_1.write('dummy', testDir + 'normal.txt'); | ||
utilsSh_1.mkdir('-p', testDir + 'dir/'); | ||
utilsSh_1.write('dummy', testDir + 'dir/.hidden'); | ||
utilsSh_1.write('dummy', testDir + 'dir/normal.txt'); | ||
(0, utilsSh_1.mkdir)('-p', testDir); | ||
(0, utilsSh_1.write)('dummy', testDir + '.hidden'); | ||
(0, utilsSh_1.write)('dummy', testDir + 'normal.txt'); | ||
(0, utilsSh_1.mkdir)('-p', testDir + 'dir/'); | ||
(0, utilsSh_1.write)('dummy', testDir + 'dir/.hidden'); | ||
(0, utilsSh_1.write)('dummy', testDir + 'dir/normal.txt'); | ||
const destDir = './goldstackLocal/work/copyAllDest/'; | ||
await utilsSh_1.copy(testDir, destDir); | ||
assert_1.default(fs_1.default.existsSync(destDir + 'normal.txt'), `Cannot find ${destDir + 'normal.txt'}`); | ||
assert_1.default(fs_1.default.existsSync(destDir + '.hidden')); | ||
assert_1.default(fs_1.default.existsSync(destDir + 'dir/.hidden')); | ||
assert_1.default(fs_1.default.existsSync(destDir + 'dir/normal.txt')); | ||
await (0, utilsSh_1.copy)(testDir, destDir); | ||
(0, assert_1.default)(fs_1.default.existsSync(destDir + 'normal.txt'), `Cannot find ${destDir + 'normal.txt'}`); | ||
(0, assert_1.default)(fs_1.default.existsSync(destDir + '.hidden')); | ||
(0, assert_1.default)(fs_1.default.existsSync(destDir + 'dir/.hidden')); | ||
(0, assert_1.default)(fs_1.default.existsSync(destDir + 'dir/normal.txt')); | ||
}); | ||
it('Should copy a single file', async () => { | ||
const testDir = './goldstackLocal/work/copySingle/'; | ||
utilsSh_1.mkdir('-p', testDir); | ||
utilsSh_1.write('dummy', testDir + 'normal.txt'); | ||
(0, utilsSh_1.mkdir)('-p', testDir); | ||
(0, utilsSh_1.write)('dummy', testDir + 'normal.txt'); | ||
const destDir = './goldstackLocal/work/copySingleDest/'; | ||
utilsSh_1.mkdir('-p', destDir); | ||
await utilsSh_1.copy(testDir + 'normal.txt', destDir); | ||
assert_1.default(fs_1.default.existsSync(destDir + 'normal.txt')); | ||
(0, utilsSh_1.mkdir)('-p', destDir); | ||
await (0, utilsSh_1.copy)(testDir + 'normal.txt', destDir); | ||
(0, assert_1.default)(fs_1.default.existsSync(destDir + 'normal.txt')); | ||
}); | ||
}); | ||
//# sourceMappingURL=utilsSh.spec.js.map |
{ | ||
"name": "@goldstack/utils-sh", | ||
"version": "0.4.12", | ||
"version": "0.4.13", | ||
"description": "Utilities for working with files and folders in a bash like manner", | ||
@@ -18,3 +18,3 @@ "keywords": [ | ||
"type": "git", | ||
"url": "https://github.com/goldstack/goldstack-lib.git" | ||
"url": "https://github.com/goldstack/goldstack.git" | ||
}, | ||
@@ -40,3 +40,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@goldstack/utils-log": "0.2.5", | ||
"@goldstack/utils-log": "0.2.6", | ||
"@types/glob": "^7.1.3", | ||
@@ -51,3 +51,3 @@ "archiver": "^5.0.0", | ||
"devDependencies": { | ||
"@goldstack/utils-git": "0.1.25", | ||
"@goldstack/utils-git": "0.1.26", | ||
"@types/archiver": "^3.1.0", | ||
@@ -61,4 +61,4 @@ "@types/jest": "^26.0.21", | ||
"ts-jest": "^26.5.4", | ||
"typescript": "^4.3.4" | ||
"typescript": "^4.4.3" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
18829
1.21%+ Added
- Removed
Updated