@platform/fs
Advanced tools
Comparing version 0.0.38 to 0.0.39
@@ -8,2 +8,3 @@ /// <reference types="node" /> | ||
import { is } from '../is'; | ||
import { folderSize } from './helpers'; | ||
export declare const fs: { | ||
@@ -14,2 +15,3 @@ glob: typeof glob; | ||
is: typeof is; | ||
folderSize: typeof folderSize; | ||
path: typeof path; | ||
@@ -16,0 +18,0 @@ join: typeof path.join; |
@@ -10,4 +10,6 @@ "use strict"; | ||
var is_1 = require("../is"); | ||
var helpers_1 = require("./helpers"); | ||
exports.fs = tslib_1.__assign({}, fsExtra, { glob: glob_1.glob, file: file_1.File, merge: merge_1.merge, | ||
is: is_1.is, | ||
folderSize: helpers_1.folderSize, | ||
path: path, join: path.join, resolve: path.resolve, dirname: path.dirname, basename: path.basename, extname: path.extname }); |
@@ -33,2 +33,30 @@ "use strict"; | ||
}); | ||
describe('folderSize', function () { | ||
it('calculates the size of a directory', function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
var res; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, _1.fs.folderSize('./src')]; | ||
case 1: | ||
res = _a.sent(); | ||
chai_1.expect(res.files.length).to.greaterThan(5); | ||
chai_1.expect(res.bytes).to.greaterThan(1000); | ||
return [2]; | ||
} | ||
}); | ||
}); }); | ||
it('nothing when path does not exist', function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
var res; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, _1.fs.folderSize('./NO_EXIST')]; | ||
case 1: | ||
res = _a.sent(); | ||
chai_1.expect(res.bytes).to.eql(0); | ||
chai_1.expect(res.files).to.eql([]); | ||
return [2]; | ||
} | ||
}); | ||
}); }); | ||
}); | ||
}); |
@@ -1,2 +0,2 @@ | ||
export declare function merge(source: string | string[], target: string, options?: { | ||
export declare function merge(sourceDir: string | string[], targetDir: string, options?: { | ||
overwrite?: boolean; | ||
@@ -3,0 +3,0 @@ pattern?: string; |
@@ -7,3 +7,3 @@ "use strict"; | ||
var is_1 = require("../is"); | ||
function merge(source, target, options) { | ||
function merge(sourceDir, targetDir, options) { | ||
if (options === void 0) { options = {}; } | ||
@@ -17,11 +17,11 @@ return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
_a = options.overwrite, overwrite = _a === void 0 ? false : _a, _b = options.pattern, pattern = _b === void 0 ? '**' : _b; | ||
return [4, is_1.is.dir(target)]; | ||
return [4, is_1.is.dir(targetDir)]; | ||
case 1: | ||
if (!(_c.sent())) { | ||
throw new Error("Target path is not a directory: " + target); | ||
throw new Error("Target path is not a directory: " + targetDir); | ||
} | ||
return [4, glob_1.glob.find(common_1.join(target, '**'))]; | ||
return [4, glob_1.glob.find(common_1.join(targetDir, '**'))]; | ||
case 2: | ||
targets = _c.sent(); | ||
dirs = Array.isArray(source) ? source : [source]; | ||
dirs = Array.isArray(sourceDir) ? sourceDir : [sourceDir]; | ||
_i = 0, dirs_1 = dirs; | ||
@@ -58,3 +58,3 @@ _c.label = 3; | ||
from: from, | ||
to: common_1.join(target, from.substr(sourceDir.length + 1)), | ||
to: common_1.join(targetDir, from.substr(sourceDir.length + 1)), | ||
}; | ||
@@ -61,0 +61,0 @@ }); |
{ | ||
"name": "@platform/fs", | ||
"version": "0.0.38", | ||
"version": "0.0.39", | ||
"description": "File system tools.", | ||
@@ -21,5 +21,5 @@ "main": "lib/index", | ||
"devDependencies": { | ||
"@platform/test": "0.0.31", | ||
"@platform/ts.libs": "3.3.4", | ||
"@types/js-yaml": "^3.12.0" | ||
"@platform/test": "0.0.32", | ||
"@platform/ts.libs": "3.3.5", | ||
"@types/js-yaml": "3.12.0" | ||
}, | ||
@@ -26,0 +26,0 @@ "files": [ |
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
74815
44
1523
4