@goldstack/utils-sh
Advanced tools
Comparing version 0.1.30 to 0.1.31
@@ -13,2 +13,13 @@ import sh from 'shelljs'; | ||
export declare const mkdir: (options: string, ...dir: string[]) => void; | ||
export declare const zip: (params: { | ||
directory: string; | ||
target: string; | ||
}) => Promise<void>; | ||
/** | ||
* Unzips a zip file into directly into a directory. | ||
*/ | ||
export declare const unzip: (params: { | ||
file: string; | ||
targetDirectory: string; | ||
}) => Promise<void>; | ||
declare const exec: (cmd: string, params?: ExecParams | undefined) => string; | ||
@@ -15,0 +26,0 @@ declare const read: (path: string) => string; |
@@ -61,3 +61,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.cd = exports.sh = exports.write = exports.read = exports.pwd = exports.exec = exports.mkdir = exports.rm = exports.rmSafe = exports.cp = exports.copy = void 0; | ||
exports.cd = exports.sh = exports.write = exports.read = exports.pwd = exports.exec = exports.unzip = exports.zip = exports.mkdir = exports.rm = exports.rmSafe = exports.cp = exports.copy = void 0; | ||
var shelljs_1 = __importStar(require("shelljs")); | ||
@@ -69,2 +69,4 @@ exports.sh = shelljs_1.default; | ||
var rimraf_1 = __importDefault(require("rimraf")); | ||
var archiver_1 = __importDefault(require("archiver")); | ||
var extract_zip_1 = __importDefault(require("extract-zip")); | ||
exports.copy = function (source, dest) { return __awaiter(void 0, void 0, void 0, function () { | ||
@@ -207,2 +209,43 @@ var sourceArr, _loop_1, _i, sourceArr_1, sourceEl; | ||
}; | ||
exports.zip = function (params) { return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, new Promise(function (resolve, reject) { | ||
var output = fs_1.default.createWriteStream(params.target); | ||
var archive = archiver_1.default('zip', { | ||
zlib: { level: 9 }, | ||
}); | ||
archive.on('warning', function (err) { | ||
console.warn(err.message); | ||
}); | ||
output.on('finish', function () { | ||
resolve(); | ||
}); | ||
output.on('error', reject); | ||
// pipe archive data to the file | ||
archive.pipe(output); | ||
archive.directory(params.directory, false); | ||
archive.finalize(); | ||
})]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
/** | ||
* Unzips a zip file into directly into a directory. | ||
*/ | ||
exports.unzip = function (params) { return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, extract_zip_1.default(params.file, { | ||
dir: path_1.default.resolve(params.targetDirectory), | ||
})]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
var exec = function (cmd, params) { | ||
@@ -209,0 +252,0 @@ var res = shelljs_1.default.exec(cmd, { silent: params === null || params === void 0 ? void 0 : params.silent }); |
{ | ||
"name": "@goldstack/utils-sh", | ||
"version": "0.1.30", | ||
"version": "0.1.31", | ||
"license": "MIT", | ||
@@ -23,2 +23,4 @@ "author": "Max Rohde", | ||
"@goldstack/utils-log": "0.1.35", | ||
"archiver": "^5.0.0", | ||
"extract-zip": "^2.0.1", | ||
"ncp": "^2.0.0", | ||
@@ -30,2 +32,3 @@ "rimraf": "^3.0.2", | ||
"@goldstack/utils-git": "0.1.21", | ||
"@types/archiver": "^3.1.0", | ||
"@types/jest": "^25.2.3", | ||
@@ -32,0 +35,0 @@ "@types/ncp": "^2.0.4", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26845
391
6
10
+ Addedarchiver@^5.0.0
+ Addedextract-zip@^2.0.1
+ Added@types/node@22.10.5(transitive)
+ Added@types/yauzl@2.10.3(transitive)
+ Addedarchiver@5.3.2(transitive)
+ Addedarchiver-utils@2.1.03.0.4(transitive)
+ Addedasync@3.2.6(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbl@4.1.0(transitive)
+ Addedbrace-expansion@2.0.1(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedbuffer-crc32@0.2.13(transitive)
+ Addedcompress-commons@4.1.2(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedcrc-32@1.2.2(transitive)
+ Addedcrc32-stream@4.0.3(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedextract-zip@2.0.1(transitive)
+ Addedfd-slicer@1.1.0(transitive)
+ Addedfs-constants@1.0.0(transitive)
+ Addedget-stream@5.2.0(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedlazystream@1.0.1(transitive)
+ Addedlodash.defaults@4.2.0(transitive)
+ Addedlodash.difference@4.5.0(transitive)
+ Addedlodash.flatten@4.4.0(transitive)
+ Addedlodash.isplainobject@4.0.6(transitive)
+ Addedlodash.union@4.6.0(transitive)
+ Addedminimatch@5.1.6(transitive)
+ Addedms@2.1.3(transitive)
+ Addednormalize-path@3.0.0(transitive)
+ Addedpend@1.2.0(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedreadable-stream@2.3.83.6.2(transitive)
+ Addedreaddir-glob@1.1.3(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedtar-stream@2.2.0(transitive)
+ Addedundici-types@6.20.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedyauzl@2.10.0(transitive)
+ Addedzip-stream@4.1.1(transitive)