@bemoje/path 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.d.ts +23 -1
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +23 -1
- package/cjs/index.js.map +1 -1
- package/cjs/lib/createFileExtensionFilter.d.ts +14 -0
- package/cjs/lib/createFileExtensionFilter.d.ts.map +1 -0
- package/cjs/lib/createFileExtensionFilter.js +27 -0
- package/cjs/lib/createFileExtensionFilter.js.map +1 -0
- package/cjs/lib/cwdpath.d.ts +13 -0
- package/cjs/lib/cwdpath.d.ts.map +1 -0
- package/cjs/lib/cwdpath.js +21 -0
- package/cjs/lib/cwdpath.js.map +1 -0
- package/cjs/lib/getAppDataPath.d.ts +5 -0
- package/cjs/lib/getAppDataPath.d.ts.map +1 -0
- package/cjs/lib/getAppDataPath.js +35 -0
- package/cjs/lib/getAppDataPath.js.map +1 -0
- package/cjs/lib/getDiskDrivesWindows.d.ts +10 -0
- package/cjs/lib/getDiskDrivesWindows.d.ts.map +1 -0
- package/cjs/lib/getDiskDrivesWindows.js +24 -0
- package/cjs/lib/getDiskDrivesWindows.js.map +1 -0
- package/cjs/lib/getDownloadsDirectory.d.ts +5 -0
- package/cjs/lib/getDownloadsDirectory.d.ts.map +1 -0
- package/cjs/lib/getDownloadsDirectory.js +18 -0
- package/cjs/lib/getDownloadsDirectory.js.map +1 -0
- package/cjs/lib/getHomeDirectory.d.ts +5 -0
- package/cjs/lib/getHomeDirectory.d.ts.map +1 -0
- package/cjs/lib/getHomeDirectory.js +16 -0
- package/cjs/lib/getHomeDirectory.js.map +1 -0
- package/cjs/lib/getTempDataPath.d.ts +7 -0
- package/cjs/lib/getTempDataPath.d.ts.map +1 -0
- package/cjs/lib/getTempDataPath.js +18 -0
- package/cjs/lib/getTempDataPath.js.map +1 -0
- package/cjs/lib/isValidFileExtension.d.ts +7 -0
- package/cjs/lib/isValidFileExtension.d.ts.map +1 -0
- package/cjs/lib/isValidFileExtension.js +13 -0
- package/cjs/lib/isValidFileExtension.js.map +1 -0
- package/cjs/lib/isValidWindowsPath.d.ts +10 -0
- package/cjs/lib/isValidWindowsPath.d.ts.map +1 -0
- package/cjs/lib/isValidWindowsPath.js +26 -0
- package/cjs/lib/isValidWindowsPath.js.map +1 -0
- package/cjs/lib/normalizeFileExtension.d.ts +23 -0
- package/cjs/lib/normalizeFileExtension.d.ts.map +1 -0
- package/cjs/lib/normalizeFileExtension.js +34 -0
- package/cjs/lib/normalizeFileExtension.js.map +1 -0
- package/cjs/lib/pathAbsoluteToRelativeCwd.d.ts +14 -0
- package/cjs/lib/pathAbsoluteToRelativeCwd.d.ts.map +1 -0
- package/cjs/lib/pathAbsoluteToRelativeCwd.js +28 -0
- package/cjs/lib/pathAbsoluteToRelativeCwd.js.map +1 -0
- package/cjs/lib/pathBasename.d.ts +19 -0
- package/cjs/lib/pathBasename.d.ts.map +1 -0
- package/cjs/lib/pathBasename.js +43 -0
- package/cjs/lib/pathBasename.js.map +1 -0
- package/cjs/lib/pathDirname.d.ts +19 -0
- package/cjs/lib/pathDirname.d.ts.map +1 -0
- package/cjs/lib/pathDirname.js +48 -0
- package/cjs/lib/pathDirname.js.map +1 -0
- package/cjs/lib/pathExtname.d.ts +14 -0
- package/cjs/lib/pathExtname.d.ts.map +1 -0
- package/cjs/lib/pathExtname.js +39 -0
- package/cjs/lib/pathExtname.js.map +1 -0
- package/cjs/lib/pathGetSeparator.d.ts +8 -0
- package/cjs/lib/pathGetSeparator.d.ts.map +1 -0
- package/cjs/lib/pathGetSeparator.js +19 -0
- package/cjs/lib/pathGetSeparator.js.map +1 -0
- package/cjs/lib/pathIsAbsolute.d.ts +19 -0
- package/cjs/lib/pathIsAbsolute.d.ts.map +1 -0
- package/cjs/lib/pathIsAbsolute.js +30 -0
- package/cjs/lib/pathIsAbsolute.js.map +1 -0
- package/cjs/lib/pathIsDotFile.d.ts +7 -0
- package/cjs/lib/pathIsDotFile.d.ts.map +1 -0
- package/cjs/lib/pathIsDotFile.js +13 -0
- package/cjs/lib/pathIsDotFile.js.map +1 -0
- package/cjs/lib/pathIsRelative.d.ts +7 -0
- package/cjs/lib/pathIsRelative.d.ts.map +1 -0
- package/cjs/lib/pathIsRelative.js +13 -0
- package/cjs/lib/pathIsRelative.js.map +1 -0
- package/cjs/lib/pathIsRelativePosix.d.ts +7 -0
- package/cjs/lib/pathIsRelativePosix.d.ts.map +1 -0
- package/cjs/lib/pathIsRelativePosix.js +13 -0
- package/cjs/lib/pathIsRelativePosix.js.map +1 -0
- package/cjs/lib/pathIsRelativeWindows.d.ts +7 -0
- package/cjs/lib/pathIsRelativeWindows.d.ts.map +1 -0
- package/cjs/lib/pathIsRelativeWindows.js +14 -0
- package/cjs/lib/pathIsRelativeWindows.js.map +1 -0
- package/cjs/lib/pathIsUnc.d.ts +7 -0
- package/cjs/lib/pathIsUnc.d.ts.map +1 -0
- package/cjs/lib/pathIsUnc.js +13 -0
- package/cjs/lib/pathIsUnc.js.map +1 -0
- package/cjs/lib/pathJoin.d.ts +5 -0
- package/cjs/lib/pathJoin.d.ts.map +1 -0
- package/cjs/lib/pathJoin.js +10 -0
- package/cjs/lib/pathJoin.js.map +1 -0
- package/cjs/lib/pathRoot.d.ts +19 -0
- package/cjs/lib/pathRoot.d.ts.map +1 -0
- package/cjs/lib/pathRoot.js +41 -0
- package/cjs/lib/pathRoot.js.map +1 -0
- package/package.json +3 -1
- package/cjs/lib/path.d.ts +0 -2
- package/cjs/lib/path.d.ts.map +0 -1
- package/cjs/lib/path.js +0 -8
- package/cjs/lib/path.js.map +0 -1
package/cjs/index.d.ts
CHANGED
|
@@ -1,2 +1,24 @@
|
|
|
1
|
-
export * from './lib/
|
|
1
|
+
export * from './lib/createFileExtensionFilter';
|
|
2
|
+
export * from './lib/cwdpath';
|
|
3
|
+
export * from './lib/getAppDataPath';
|
|
4
|
+
export * from './lib/getDiskDrivesWindows';
|
|
5
|
+
export * from './lib/getDownloadsDirectory';
|
|
6
|
+
export * from './lib/getHomeDirectory';
|
|
7
|
+
export * from './lib/getTempDataPath';
|
|
8
|
+
export * from './lib/isValidFileExtension';
|
|
9
|
+
export * from './lib/isValidWindowsPath';
|
|
10
|
+
export * from './lib/normalizeFileExtension';
|
|
11
|
+
export * from './lib/pathAbsoluteToRelativeCwd';
|
|
12
|
+
export * from './lib/pathBasename';
|
|
13
|
+
export * from './lib/pathDirname';
|
|
14
|
+
export * from './lib/pathExtname';
|
|
15
|
+
export * from './lib/pathGetSeparator';
|
|
16
|
+
export * from './lib/pathIsAbsolute';
|
|
17
|
+
export * from './lib/pathIsDotFile';
|
|
18
|
+
export * from './lib/pathIsRelative';
|
|
19
|
+
export * from './lib/pathIsRelativePosix';
|
|
20
|
+
export * from './lib/pathIsRelativeWindows';
|
|
21
|
+
export * from './lib/pathIsUnc';
|
|
22
|
+
export * from './lib/pathJoin';
|
|
23
|
+
export * from './lib/pathRoot';
|
|
2
24
|
//# sourceMappingURL=index.d.ts.map
|
package/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/path/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/path/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAA;AAC/C,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA;AACpC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,iCAAiC,CAAA;AAC/C,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA"}
|
package/cjs/index.js
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./lib/
|
|
4
|
+
tslib_1.__exportStar(require("./lib/createFileExtensionFilter"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./lib/cwdpath"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./lib/getAppDataPath"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./lib/getDiskDrivesWindows"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./lib/getDownloadsDirectory"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./lib/getHomeDirectory"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./lib/getTempDataPath"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./lib/isValidFileExtension"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./lib/isValidWindowsPath"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./lib/normalizeFileExtension"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./lib/pathAbsoluteToRelativeCwd"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./lib/pathBasename"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./lib/pathDirname"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./lib/pathExtname"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./lib/pathGetSeparator"), exports);
|
|
19
|
+
tslib_1.__exportStar(require("./lib/pathIsAbsolute"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./lib/pathIsDotFile"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./lib/pathIsRelative"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./lib/pathIsRelativePosix"), exports);
|
|
23
|
+
tslib_1.__exportStar(require("./lib/pathIsRelativeWindows"), exports);
|
|
24
|
+
tslib_1.__exportStar(require("./lib/pathIsUnc"), exports);
|
|
25
|
+
tslib_1.__exportStar(require("./lib/pathJoin"), exports);
|
|
26
|
+
tslib_1.__exportStar(require("./lib/pathRoot"), exports);
|
|
5
27
|
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/path/src/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/path/src/index.ts"],"names":[],"mappings":";;;AAAA,0EAA+C;AAC/C,wDAA6B;AAC7B,+DAAoC;AACpC,qEAA0C;AAC1C,sEAA2C;AAC3C,iEAAsC;AACtC,gEAAqC;AACrC,qEAA0C;AAC1C,mEAAwC;AACxC,uEAA4C;AAC5C,0EAA+C;AAC/C,6DAAkC;AAClC,4DAAiC;AACjC,4DAAiC;AACjC,iEAAsC;AACtC,+DAAoC;AACpC,8DAAmC;AACnC,+DAAoC;AACpC,oEAAyC;AACzC,sEAA2C;AAC3C,0DAA+B;AAC/B,yDAA8B;AAC9B,yDAA8B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Takes a list of file extensions and returns a filter function that returns true if a filepath/filename passed to it contains one of the given file extensions.
|
|
3
|
+
* @remarks If no file extensions are provided, the filter will always return true.
|
|
4
|
+
* @returns A function that takes a filepath and returns true if the filepath has one of the specified file extensions, false otherwise.
|
|
5
|
+
* @param fileExtensions file extensions
|
|
6
|
+
* @example ```ts
|
|
7
|
+
* createFileExtensionFilter(['.ts', '.tsx'])('index.ts');
|
|
8
|
+
* //=> true
|
|
9
|
+
* createFileExtensionFilter(['.ts', '.tsx'])('index.js');
|
|
10
|
+
* //=> false
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function createFileExtensionFilter(fileExtensions: string[]): (filepath: string) => boolean;
|
|
14
|
+
//# sourceMappingURL=createFileExtensionFilter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFileExtensionFilter.d.ts","sourceRoot":"","sources":["../../../../../packages/path/src/lib/createFileExtensionFilter.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAMjG"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFileExtensionFilter = void 0;
|
|
4
|
+
const normalizeFileExtension_1 = require("./normalizeFileExtension");
|
|
5
|
+
const pathExtname_1 = require("./pathExtname");
|
|
6
|
+
/**
|
|
7
|
+
* Takes a list of file extensions and returns a filter function that returns true if a filepath/filename passed to it contains one of the given file extensions.
|
|
8
|
+
* @remarks If no file extensions are provided, the filter will always return true.
|
|
9
|
+
* @returns A function that takes a filepath and returns true if the filepath has one of the specified file extensions, false otherwise.
|
|
10
|
+
* @param fileExtensions file extensions
|
|
11
|
+
* @example ```ts
|
|
12
|
+
* createFileExtensionFilter(['.ts', '.tsx'])('index.ts');
|
|
13
|
+
* //=> true
|
|
14
|
+
* createFileExtensionFilter(['.ts', '.tsx'])('index.js');
|
|
15
|
+
* //=> false
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
function createFileExtensionFilter(fileExtensions) {
|
|
19
|
+
if (!fileExtensions.length)
|
|
20
|
+
return (() => true);
|
|
21
|
+
const set = new Set(fileExtensions.map(normalizeFileExtension_1.normalizeFileExtension));
|
|
22
|
+
return (filepath) => {
|
|
23
|
+
return set.has((0, normalizeFileExtension_1.normalizeFileExtension)((0, pathExtname_1.pathExtname)(filepath)));
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.createFileExtensionFilter = createFileExtensionFilter;
|
|
27
|
+
//# sourceMappingURL=createFileExtensionFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFileExtensionFilter.js","sourceRoot":"","sources":["../../../../../packages/path/src/lib/createFileExtensionFilter.ts"],"names":[],"mappings":";;;AAAA,qEAAiE;AACjE,+CAA2C;AAE3C;;;;;;;;;;;GAWG;AACH,SAAgB,yBAAyB,CAAC,cAAwB;IAChE,IAAI,CAAC,cAAc,CAAC,MAAM;QAAE,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAkC,CAAA;IAChF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAS,cAAc,CAAC,GAAG,CAAC,+CAAsB,CAAC,CAAC,CAAA;IACvE,OAAO,CAAC,QAAgB,EAAE,EAAE;QAC1B,OAAO,GAAG,CAAC,GAAG,CAAC,IAAA,+CAAsB,EAAC,IAAA,yBAAW,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;IAC/D,CAAC,CAAA;AACH,CAAC;AAND,8DAMC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Joins the given path segments to the current working directory path, and normalizes the resulting path.
|
|
3
|
+
* @remarks
|
|
4
|
+
* The function uses the `path.join` method from the Node.js `path` module, and the `process.cwd` method from the Node.js `process` module.
|
|
5
|
+
* @param paths - The path segments to join to the current working directory path.
|
|
6
|
+
* @returns The resulting path.
|
|
7
|
+
* @example ```ts
|
|
8
|
+
* console.log(cwdpath('src', 'index.ts'));
|
|
9
|
+
* //=> '{working_directory}/src/index.ts'
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function cwdpath(...paths: string[]): string;
|
|
13
|
+
//# sourceMappingURL=cwdpath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cwdpath.d.ts","sourceRoot":"","sources":["../../../../../packages/path/src/lib/cwdpath.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAElD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cwdpath = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
+
/**
|
|
7
|
+
* Joins the given path segments to the current working directory path, and normalizes the resulting path.
|
|
8
|
+
* @remarks
|
|
9
|
+
* The function uses the `path.join` method from the Node.js `path` module, and the `process.cwd` method from the Node.js `process` module.
|
|
10
|
+
* @param paths - The path segments to join to the current working directory path.
|
|
11
|
+
* @returns The resulting path.
|
|
12
|
+
* @example ```ts
|
|
13
|
+
* console.log(cwdpath('src', 'index.ts'));
|
|
14
|
+
* //=> '{working_directory}/src/index.ts'
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
function cwdpath(...paths) {
|
|
18
|
+
return path_1.default.join(process.cwd(), ...paths);
|
|
19
|
+
}
|
|
20
|
+
exports.cwdpath = cwdpath;
|
|
21
|
+
//# sourceMappingURL=cwdpath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cwdpath.js","sourceRoot":"","sources":["../../../../../packages/path/src/lib/cwdpath.ts"],"names":[],"mappings":";;;;AAAA,wDAAuB;AAEvB;;;;;;;;;;GAUG;AACH,SAAgB,OAAO,CAAC,GAAG,KAAe;IACxC,OAAO,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,KAAK,CAAC,CAAA;AAC3C,CAAC;AAFD,0BAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAppDataPath.d.ts","sourceRoot":"","sources":["../../../../../packages/path/src/lib/getAppDataPath.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,UAiBpE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAppDataPath = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const os_1 = tslib_1.__importDefault(require("os"));
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
+
const os_2 = require("@bemoje/os");
|
|
8
|
+
/**
|
|
9
|
+
* Get the app data path, depending on the current OS (win, osx, linux).
|
|
10
|
+
*/
|
|
11
|
+
function getAppDataPath(appName, ...subdirs) {
|
|
12
|
+
let appDataPath = process.env['APPDATA'];
|
|
13
|
+
if (!appDataPath) {
|
|
14
|
+
const OS = (0, os_2.getOS)();
|
|
15
|
+
if (OS === 'windows') {
|
|
16
|
+
appDataPath = path_1.default.join(os_1.default.homedir(), 'AppData', 'Roaming');
|
|
17
|
+
}
|
|
18
|
+
else if (OS === 'osx') {
|
|
19
|
+
appDataPath = path_1.default.join(os_1.default.homedir(), 'Library', 'Application Support');
|
|
20
|
+
}
|
|
21
|
+
else if (OS === 'linux') {
|
|
22
|
+
appDataPath = path_1.default.join(os_1.default.homedir(), '.config');
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
throw new Error('Could not find an appropriate app data path');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (!appName)
|
|
29
|
+
return appDataPath;
|
|
30
|
+
if (appDataPath === os_1.default.homedir())
|
|
31
|
+
appName = '.' + appName;
|
|
32
|
+
return path_1.default.join(appDataPath, appName, ...subdirs);
|
|
33
|
+
}
|
|
34
|
+
exports.getAppDataPath = getAppDataPath;
|
|
35
|
+
//# sourceMappingURL=getAppDataPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAppDataPath.js","sourceRoot":"","sources":["../../../../../packages/path/src/lib/getAppDataPath.ts"],"names":[],"mappings":";;;;AAAA,oDAAmB;AACnB,wDAAuB;AACvB,mCAAkC;AAElC;;GAEG;AACH,SAAgB,cAAc,CAAC,OAAgB,EAAE,GAAG,OAAiB;IACnE,IAAI,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;IACxC,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,EAAE,GAAG,IAAA,UAAK,GAAE,CAAA;QAClB,IAAI,EAAE,KAAK,SAAS,EAAE;YACpB,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA;SAC5D;aAAM,IAAI,EAAE,KAAK,KAAK,EAAE;YACvB,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,qBAAqB,CAAC,CAAA;SACxE;aAAM,IAAI,EAAE,KAAK,OAAO,EAAE;YACzB,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAA;SACjD;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;SAC/D;KACF;IACD,IAAI,CAAC,OAAO;QAAE,OAAO,WAAW,CAAA;IAChC,IAAI,WAAW,KAAK,YAAE,CAAC,OAAO,EAAE;QAAE,OAAO,GAAG,GAAG,GAAG,OAAO,CAAA;IACzD,OAAO,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAA;AACpD,CAAC;AAjBD,wCAiBC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function retrieves information about the disk drives on a Windows system.
|
|
3
|
+
* It uses the Windows Management Instrumentation (WMI) to query the system for this information.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* getDiskDrivesWindows()
|
|
7
|
+
* //=> [ 'C:\\', 'G:\\' ]
|
|
8
|
+
*/
|
|
9
|
+
export declare function getDiskDrivesWindows(): string[];
|
|
10
|
+
//# sourceMappingURL=getDiskDrivesWindows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDiskDrivesWindows.d.ts","sourceRoot":"","sources":["../../../../../packages/path/src/lib/getDiskDrivesWindows.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,EAAE,CAO/C"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDiskDrivesWindows = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
+
/**
|
|
8
|
+
* This function retrieves information about the disk drives on a Windows system.
|
|
9
|
+
* It uses the Windows Management Instrumentation (WMI) to query the system for this information.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* getDiskDrivesWindows()
|
|
13
|
+
* //=> [ 'C:\\', 'G:\\' ]
|
|
14
|
+
*/
|
|
15
|
+
function getDiskDrivesWindows() {
|
|
16
|
+
return (0, child_process_1.execSync)('wmic logicaldisk get name')
|
|
17
|
+
.toString()
|
|
18
|
+
.split('\n')
|
|
19
|
+
.map((s) => s.trim())
|
|
20
|
+
.filter((s) => /^[a-z]:/i.test(s))
|
|
21
|
+
.map((s) => s.substring(0, 2) + path_1.default.sep);
|
|
22
|
+
}
|
|
23
|
+
exports.getDiskDrivesWindows = getDiskDrivesWindows;
|
|
24
|
+
//# sourceMappingURL=getDiskDrivesWindows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDiskDrivesWindows.js","sourceRoot":"","sources":["../../../../../packages/path/src/lib/getDiskDrivesWindows.ts"],"names":[],"mappings":";;;;AAAA,iDAAwC;AACxC,wDAAuB;AAEvB;;;;;;;GAOG;AACH,SAAgB,oBAAoB;IAClC,OAAO,IAAA,wBAAQ,EAAC,2BAA2B,CAAC;SACzC,QAAQ,EAAE;SACV,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,cAAI,CAAC,GAAG,CAAC,CAAA;AAC7C,CAAC;AAPD,oDAOC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDownloadsDirectory.d.ts","sourceRoot":"","sources":["../../../../../packages/path/src/lib/getDownloadsDirectory.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAI9C"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDownloadsDirectory = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
+
const getHomeDirectory_1 = require("./getHomeDirectory");
|
|
8
|
+
/**
|
|
9
|
+
* Returns the downloads directory of the current user.
|
|
10
|
+
*/
|
|
11
|
+
function getDownloadsDirectory() {
|
|
12
|
+
const result = path_1.default.join((0, getHomeDirectory_1.getHomeDirectory)(), 'Downloads');
|
|
13
|
+
if (!fs_extra_1.default.existsSync(result))
|
|
14
|
+
throw new Error('Downloads directory does not exist');
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
exports.getDownloadsDirectory = getDownloadsDirectory;
|
|
18
|
+
//# sourceMappingURL=getDownloadsDirectory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDownloadsDirectory.js","sourceRoot":"","sources":["../../../../../packages/path/src/lib/getDownloadsDirectory.ts"],"names":[],"mappings":";;;;AAAA,gEAAyB;AACzB,wDAAuB;AACvB,yDAAqD;AAErD;;GAEG;AACH,SAAgB,qBAAqB;IACnC,MAAM,MAAM,GAAG,cAAI,CAAC,IAAI,CAAC,IAAA,mCAAgB,GAAE,EAAE,WAAW,CAAC,CAAA;IACzD,IAAI,CAAC,kBAAE,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;IACjF,OAAO,MAAM,CAAA;AACf,CAAC;AAJD,sDAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getHomeDirectory.d.ts","sourceRoot":"","sources":["../../../../../packages/path/src/lib/getHomeDirectory.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAIzC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getHomeDirectory = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
+
/**
|
|
7
|
+
* Returns the home directory of the current user.
|
|
8
|
+
*/
|
|
9
|
+
function getHomeDirectory() {
|
|
10
|
+
const home = process.env['HOME'] || process.env['USERPROFILE'];
|
|
11
|
+
if (!home)
|
|
12
|
+
throw new Error('Home directory not found');
|
|
13
|
+
return path_1.default.resolve(home);
|
|
14
|
+
}
|
|
15
|
+
exports.getHomeDirectory = getHomeDirectory;
|
|
16
|
+
//# sourceMappingURL=getHomeDirectory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getHomeDirectory.js","sourceRoot":"","sources":["../../../../../packages/path/src/lib/getHomeDirectory.ts"],"names":[],"mappings":";;;;AAAA,wDAAuB;AAEvB;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;IAC9D,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;IACtD,OAAO,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;AAC3B,CAAC;AAJD,4CAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTempDataPath.d.ts","sourceRoot":"","sources":["../../../../../packages/path/src/lib/getTempDataPath.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAE1D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTempDataPath = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
6
|
+
const os_1 = tslib_1.__importDefault(require("os"));
|
|
7
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
|
+
/**
|
|
9
|
+
* Returns a path to the os tmpdir location.
|
|
10
|
+
*
|
|
11
|
+
* @param paths - The paths to join to the os tmpdir location.
|
|
12
|
+
*/
|
|
13
|
+
function getTempDataPath(...paths) {
|
|
14
|
+
return path_1.default.join(tempdir, ...paths);
|
|
15
|
+
}
|
|
16
|
+
exports.getTempDataPath = getTempDataPath;
|
|
17
|
+
const tempdir = fs_extra_1.default.realpathSync(os_1.default.tmpdir());
|
|
18
|
+
//# sourceMappingURL=getTempDataPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTempDataPath.js","sourceRoot":"","sources":["../../../../../packages/path/src/lib/getTempDataPath.ts"],"names":[],"mappings":";;;;AAAA,gEAAyB;AACzB,oDAAmB;AACnB,wDAAuB;AAEvB;;;;GAIG;AACH,SAAgB,eAAe,CAAC,GAAG,KAAe;IAChD,OAAO,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,CAAA;AACrC,CAAC;AAFD,0CAEC;AAED,MAAM,OAAO,GAAG,kBAAE,CAAC,YAAY,CAAC,YAAE,CAAC,MAAM,EAAE,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isValidFileExtension.d.ts","sourceRoot":"","sources":["../../../../../packages/path/src/lib/isValidFileExtension.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEzD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isValidFileExtension = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Check if a file extension is valid.
|
|
6
|
+
*
|
|
7
|
+
* @param ext - The file extension to check.
|
|
8
|
+
*/
|
|
9
|
+
function isValidFileExtension(ext) {
|
|
10
|
+
return !!ext && ext !== '.' && !/[<>"|?*:]/.test(ext);
|
|
11
|
+
}
|
|
12
|
+
exports.isValidFileExtension = isValidFileExtension;
|
|
13
|
+
//# sourceMappingURL=isValidFileExtension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isValidFileExtension.js","sourceRoot":"","sources":["../../../../../packages/path/src/lib/isValidFileExtension.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,SAAgB,oBAAoB,CAAC,GAAW;IAC9C,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACvD,CAAC;AAFD,oDAEC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check whether a provided windows filesystem path string is valid according to:
|
|
3
|
+
* https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
|
|
4
|
+
* @param path The path to validate.
|
|
5
|
+
* @throws If the path is invalid and the `assert` option is true.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isValidWindowsPath(path: string, options?: {
|
|
8
|
+
extendedMaxLength?: boolean;
|
|
9
|
+
}): boolean;
|
|
10
|
+
//# sourceMappingURL=isValidWindowsPath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isValidWindowsPath.d.ts","sourceRoot":"","sources":["../../../../../packages/path/src/lib/isValidWindowsPath.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CASnG"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isValidWindowsPath = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Check whether a provided windows filesystem path string is valid according to:
|
|
6
|
+
* https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
|
|
7
|
+
* @param path The path to validate.
|
|
8
|
+
* @throws If the path is invalid and the `assert` option is true.
|
|
9
|
+
*/
|
|
10
|
+
function isValidWindowsPath(path, options) {
|
|
11
|
+
if (path.length === 0)
|
|
12
|
+
return false;
|
|
13
|
+
if (path.indexOf('/') !== -1 && path.indexOf('\\') !== -1)
|
|
14
|
+
return false;
|
|
15
|
+
const maxLength = (options && options.extendedMaxLength ? 32767 : 260) - 12;
|
|
16
|
+
if (path.length > maxLength)
|
|
17
|
+
return false;
|
|
18
|
+
const noDriveLetter = /^\w:(\\|\/)/g.test(path) ? path.substring(2) : path;
|
|
19
|
+
if (/[<>"|?*:]/g.test(noDriveLetter))
|
|
20
|
+
return false;
|
|
21
|
+
if (/(\\|\/)(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])((\\|\/)|$)/g.test(path))
|
|
22
|
+
return false;
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
exports.isValidWindowsPath = isValidWindowsPath;
|
|
26
|
+
//# sourceMappingURL=isValidWindowsPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isValidWindowsPath.js","sourceRoot":"","sources":["../../../../../packages/path/src/lib/isValidWindowsPath.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,IAAY,EAAE,OAAyC;IACxF,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IACnC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAAE,OAAO,KAAK,CAAA;IACvE,MAAM,SAAS,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAA;IAC3E,IAAI,IAAI,CAAC,MAAM,GAAG,SAAS;QAAE,OAAO,KAAK,CAAA;IACzC,MAAM,aAAa,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IAC1E,IAAI,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC;QAAE,OAAO,KAAK,CAAA;IAClD,IAAI,wDAAwD,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAA;IACrF,OAAO,IAAI,CAAA;AACb,CAAC;AATD,gDASC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize a file extension to the form: .[ext]
|
|
3
|
+
* Anything before the last "." is not returned.
|
|
4
|
+
* @returns The normalized file extension.
|
|
5
|
+
* @throws If the extension contains illegal characters or is equal to '.'
|
|
6
|
+
* @param ext file extension
|
|
7
|
+
* @example ```ts
|
|
8
|
+
* normalizeFileExtension('jpg');;
|
|
9
|
+
* //=> '.jpg'
|
|
10
|
+
* normalizeFileExtension('.jpg');;
|
|
11
|
+
* //=> '.jpg'
|
|
12
|
+
* normalizeFileExtension('..jpg');;
|
|
13
|
+
* //=> '.jpg'
|
|
14
|
+
* normalizeFileExtension('');;
|
|
15
|
+
* //=> ''
|
|
16
|
+
* normalizeFileExtension('.');;
|
|
17
|
+
* //=> ''
|
|
18
|
+
* normalizeFileExtension('jpg|png');;
|
|
19
|
+
* //=> Error
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function normalizeFileExtension(ext: string): string;
|
|
23
|
+
//# sourceMappingURL=normalizeFileExtension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeFileExtension.d.ts","sourceRoot":"","sources":["../../../../../packages/path/src/lib/normalizeFileExtension.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK1D"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeFileExtension = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Normalize a file extension to the form: .[ext]
|
|
6
|
+
* Anything before the last "." is not returned.
|
|
7
|
+
* @returns The normalized file extension.
|
|
8
|
+
* @throws If the extension contains illegal characters or is equal to '.'
|
|
9
|
+
* @param ext file extension
|
|
10
|
+
* @example ```ts
|
|
11
|
+
* normalizeFileExtension('jpg');;
|
|
12
|
+
* //=> '.jpg'
|
|
13
|
+
* normalizeFileExtension('.jpg');;
|
|
14
|
+
* //=> '.jpg'
|
|
15
|
+
* normalizeFileExtension('..jpg');;
|
|
16
|
+
* //=> '.jpg'
|
|
17
|
+
* normalizeFileExtension('');;
|
|
18
|
+
* //=> ''
|
|
19
|
+
* normalizeFileExtension('.');;
|
|
20
|
+
* //=> ''
|
|
21
|
+
* normalizeFileExtension('jpg|png');;
|
|
22
|
+
* //=> Error
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
function normalizeFileExtension(ext) {
|
|
26
|
+
if (!ext || ext === '.')
|
|
27
|
+
return '';
|
|
28
|
+
ext = ext.toLowerCase();
|
|
29
|
+
if (!ext.startsWith('.'))
|
|
30
|
+
ext = '.' + ext;
|
|
31
|
+
return ext.substring(ext.lastIndexOf('.'));
|
|
32
|
+
}
|
|
33
|
+
exports.normalizeFileExtension = normalizeFileExtension;
|
|
34
|
+
//# sourceMappingURL=normalizeFileExtension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeFileExtension.js","sourceRoot":"","sources":["../../../../../packages/path/src/lib/normalizeFileExtension.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,sBAAsB,CAAC,GAAW;IAChD,IAAI,CAAC,GAAG,IAAI,GAAG,KAAK,GAAG;QAAE,OAAO,EAAE,CAAA;IAClC,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAA;IACvB,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;IACzC,OAAO,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAA;AAC5C,CAAC;AALD,wDAKC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* If the filepath is somewhere in the current working directory, it can be converted into a relative path.
|
|
3
|
+
* @remarks This function takes an absolute path as input and returns a relative path. It replaces the current working directory in the path with an empty string,
|
|
4
|
+
* replaces all backslashes with forward slashes, and removes any leading forward slashes.
|
|
5
|
+
* @param workingDirectory The directory relative to which the path should be converted. Defaults to the current working directory.
|
|
6
|
+
* @returns The relative path.
|
|
7
|
+
* @param absolute the absolute filepath to convert.
|
|
8
|
+
* @example ```ts
|
|
9
|
+
* pathAbsoluteToRelativeCwd(__filename)
|
|
10
|
+
* //=> 'src/pathAbsoluteToRelativeCwd.ts'
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function pathAbsoluteToRelativeCwd(absolute: string, workingDirectory?: string): string;
|
|
14
|
+
//# sourceMappingURL=pathAbsoluteToRelativeCwd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathAbsoluteToRelativeCwd.d.ts","sourceRoot":"","sources":["../../../../../packages/path/src/lib/pathAbsoluteToRelativeCwd.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,EAAE,gBAAgB,SAAgB,GAAG,MAAM,CAOpG"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pathAbsoluteToRelativeCwd = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
+
/**
|
|
7
|
+
* If the filepath is somewhere in the current working directory, it can be converted into a relative path.
|
|
8
|
+
* @remarks This function takes an absolute path as input and returns a relative path. It replaces the current working directory in the path with an empty string,
|
|
9
|
+
* replaces all backslashes with forward slashes, and removes any leading forward slashes.
|
|
10
|
+
* @param workingDirectory The directory relative to which the path should be converted. Defaults to the current working directory.
|
|
11
|
+
* @returns The relative path.
|
|
12
|
+
* @param absolute the absolute filepath to convert.
|
|
13
|
+
* @example ```ts
|
|
14
|
+
* pathAbsoluteToRelativeCwd(__filename)
|
|
15
|
+
* //=> 'src/pathAbsoluteToRelativeCwd.ts'
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
function pathAbsoluteToRelativeCwd(absolute, workingDirectory = process.cwd()) {
|
|
19
|
+
absolute = path_1.default.normalize(absolute);
|
|
20
|
+
if (absolute === workingDirectory)
|
|
21
|
+
return './';
|
|
22
|
+
return absolute.replace(new RegExp(regexEscapeString(path_1.default.normalize(workingDirectory) + path_1.default.sep), 'i'), '');
|
|
23
|
+
function regexEscapeString(str) {
|
|
24
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.pathAbsoluteToRelativeCwd = pathAbsoluteToRelativeCwd;
|
|
28
|
+
//# sourceMappingURL=pathAbsoluteToRelativeCwd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathAbsoluteToRelativeCwd.js","sourceRoot":"","sources":["../../../../../packages/path/src/lib/pathAbsoluteToRelativeCwd.ts"],"names":[],"mappings":";;;;AAAA,wDAAuB;AAEvB;;;;;;;;;;;GAWG;AACH,SAAgB,yBAAyB,CAAC,QAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,GAAG,EAAE;IAC1F,QAAQ,GAAG,cAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;IACnC,IAAI,QAAQ,KAAK,gBAAgB;QAAE,OAAO,IAAI,CAAA;IAC9C,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,iBAAiB,CAAC,cAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,GAAG,cAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAA;IAC5G,SAAS,iBAAiB,CAAC,GAAW;QACpC,OAAO,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAA,CAAC,oCAAoC;IACxF,CAAC;AACH,CAAC;AAPD,8DAOC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identical to @see path.basename, but faster.
|
|
3
|
+
*
|
|
4
|
+
* @param filepath The path to evaluate.
|
|
5
|
+
*/
|
|
6
|
+
export declare const pathBasename: typeof pathBasenameWindows;
|
|
7
|
+
/**
|
|
8
|
+
* Identical to @see path.posix.basename, but faster.
|
|
9
|
+
*
|
|
10
|
+
* @param filepath The path to evaluate.
|
|
11
|
+
*/
|
|
12
|
+
export declare function pathBasenamePosix(fspath: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Identical to @see path.win32.basename, but faster.
|
|
15
|
+
*
|
|
16
|
+
* @param filepath The path to evaluate.
|
|
17
|
+
*/
|
|
18
|
+
export declare function pathBasenameWindows(fspath: string): string;
|
|
19
|
+
//# sourceMappingURL=pathBasename.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathBasename.d.ts","sourceRoot":"","sources":["../../../../../packages/path/src/lib/pathBasename.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,YAAY,4BAAwD,CAAA;AAEjF;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKxD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAG1D"}
|