@jakubmazanec/fs-utils 0.2.18-unstable.f50b9d9c → 0.2.18
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/README.md +1 -1
- package/build/createTempDirectory.js +0 -1
- package/build/createTempDirectory.js.map +1 -1
- package/build/ensureEmptyDirectory.js +0 -1
- package/build/ensureEmptyDirectory.js.map +1 -1
- package/build/findDirectories.js +0 -1
- package/build/findDirectories.js.map +1 -1
- package/build/findExistingDirectory.js +0 -1
- package/build/findExistingDirectory.js.map +1 -1
- package/build/isDirectory.js +0 -1
- package/build/isDirectory.js.map +1 -1
- package/build/isEmptyDirectory.js +0 -1
- package/build/isEmptyDirectory.js.map +1 -1
- package/build/isRootPath.js +0 -1
- package/build/isRootPath.js.map +1 -1
- package/build/main.js +0 -1
- package/build/main.js.map +1 -1
- package/build/pathToPosixPath.js +0 -1
- package/build/pathToPosixPath.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../source/createTempDirectory.ts"],
|
|
4
4
|
"sourcesContent": ["import fs from 'fs-extra';\nimport os from 'node:os';\nimport path from 'node:path';\n\n/**\n * Creates a unique temporary directory in the operating system's default directory for temporary files. The name of the directory is random, but can be prefixed with a custom string.\n *\n * @param prefix The new directory name prefix.\n * @returns The new directory name.\n * */\nexport async function createTempDirectory(prefix?: string) {\n return fs.mkdtemp(path.join(os.tmpdir(), prefix ?? '/'));\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AAQjB,sBAAsB,oBAAoB,QAAiB;AACzD,SAAO,GAAG,QAAQ,KAAK,KAAK,GAAG,OAAO,GAAG,UAAU,GAAG,CAAC;AACzD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../source/ensureEmptyDirectory.ts"],
|
|
4
4
|
"sourcesContent": ["import fs from 'fs-extra';\nimport path from 'node:path';\n\nimport {isEmptyDirectory} from './isEmptyDirectory.js';\n\n/**\n * {@link ensureEmptyDirectory} options parameter.\n */\nexport type EnsureEmptyDirectoryOptions = {\n /** Allows presence of a `.git` directory */\n allowGit?: boolean | undefined;\n};\n\n/**\n * Ensures that a path is actually an empty directory. If the path doesn't exist, the directory is created; if the path exists but isn't an ampty directory, error is thrown.\n *\n * @param path The target path.\n */\nexport async function ensureEmptyDirectory(\n targetPath: string,\n {allowGit}: EnsureEmptyDirectoryOptions = {},\n) {\n await fs.ensureDir(targetPath);\n\n if (!(await isEmptyDirectory(targetPath))) {\n if (!allowGit) {\n throw new Error(`Directory \"${targetPath}\" must be empty.`);\n }\n\n let files = await fs.readdir(targetPath);\n\n if (files.length !== 1) {\n throw new Error(`Directory \"${targetPath}\" can contain only \".git\" directory.`);\n }\n\n if (files[0] !== '.git') {\n throw new Error(`Directory \"${targetPath}\" can contain only \".git\" directory.`);\n }\n\n if (!(await fs.stat(path.join(targetPath, files[0]))).isDirectory()) {\n throw new Error(`Directory \"${targetPath}\" can contain only \".git\" directory.`);\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAEjB,SAAQ,wBAAuB;AAe/B,sBAAsB,qBACpB,YACA,EAAC,SAAQ,IAAiC,CAAC,GAC3C;AACA,QAAM,GAAG,UAAU,UAAU;AAE7B,MAAI,CAAE,MAAM,iBAAiB,UAAU,GAAI;AACzC,QAAI,CAAC,UAAU;AACb,YAAM,IAAI,MAAM,cAAc,UAAU,kBAAkB;AAAA,IAC5D;AAEA,QAAI,QAAQ,MAAM,GAAG,QAAQ,UAAU;AAEvC,QAAI,MAAM,WAAW,GAAG;AACtB,YAAM,IAAI,MAAM,cAAc,UAAU,sCAAsC;AAAA,IAChF;AAEA,QAAI,MAAM,CAAC,MAAM,QAAQ;AACvB,YAAM,IAAI,MAAM,cAAc,UAAU,sCAAsC;AAAA,IAChF;AAEA,QAAI,EAAE,MAAM,GAAG,KAAK,KAAK,KAAK,YAAY,MAAM,CAAC,CAAC,CAAC,GAAG,YAAY,GAAG;AACnE,YAAM,IAAI,MAAM,cAAc,UAAU,sCAAsC;AAAA,IAChF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/findDirectories.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../source/findDirectories.ts"],
|
|
4
4
|
"sourcesContent": ["import fs from 'fs-extra';\n\n/**\n * Finds all directories that are direct sub-directories of a path.\n *\n * @param searchPath Search path.\n * @returns The list of directory names.\n */\nexport async function findDirectories(searchPath: string): Promise<string[]> {\n return (await fs.readdir(searchPath, {withFileTypes: true}))\n .filter((dirent) => dirent.isDirectory())\n .map((dirent) => dirent.name);\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,OAAO,QAAQ;AAQf,sBAAsB,gBAAgB,YAAuC;AAC3E,UAAQ,MAAM,GAAG,QAAQ,YAAY,EAAC,eAAe,KAAI,CAAC,GACvD,OAAO,CAAC,WAAW,OAAO,YAAY,CAAC,EACvC,IAAI,CAAC,WAAW,OAAO,IAAI;AAChC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../source/findExistingDirectory.ts"],
|
|
4
4
|
"sourcesContent": ["import fs from 'fs-extra';\nimport path from 'node:path';\n\nimport {isDirectory} from './isDirectory.js';\n\n/**\n * Travels up the file system tree from a starting path and returns path of the first existing directory.\n *\n * ```TypeScript\n * let result = findExistingDirectory('/foo/bar/baz'); // if there is no `bar` directory, `result` is `'/foo'`\n * ```\n *\n * @param searchPath Search path.\n */\nexport async function findExistingDirectory(searchPath: string) {\n let result = searchPath;\n let pathExists = await fs.pathExists(result);\n\n while (!pathExists) {\n result = path.dirname(result);\n pathExists = await fs.pathExists(result);\n }\n\n let isResultDirectory = await isDirectory(result);\n\n if (!isResultDirectory) {\n result = path.dirname(result);\n }\n\n return result;\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAEjB,SAAQ,mBAAkB;AAW1B,sBAAsB,sBAAsB,YAAoB;AAC9D,MAAI,SAAS;AACb,MAAI,aAAa,MAAM,GAAG,WAAW,MAAM;AAE3C,SAAO,CAAC,YAAY;AAClB,aAAS,KAAK,QAAQ,MAAM;AAC5B,iBAAa,MAAM,GAAG,WAAW,MAAM;AAAA,EACzC;AAEA,MAAI,oBAAoB,MAAM,YAAY,MAAM;AAEhD,MAAI,CAAC,mBAAmB;AACtB,aAAS,KAAK,QAAQ,MAAM;AAAA,EAC9B;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/isDirectory.js
CHANGED
package/build/isDirectory.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../source/isDirectory.ts"],
|
|
4
4
|
"sourcesContent": ["import fs from 'fs-extra';\n\n/**\n * Checks if a path is a directory.\n *\n * @param path The path to check.\n * @returns `true` if path is a directory, `false` otherwise.\n */\nexport async function isDirectory(path: string): Promise<boolean> {\n let stat = await fs.lstat(path);\n\n return stat.isDirectory();\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,OAAO,QAAQ;AAQf,sBAAsB,YAAY,MAAgC;AAChE,MAAI,OAAO,MAAM,GAAG,MAAM,IAAI;AAE9B,SAAO,KAAK,YAAY;AAC1B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../source/isEmptyDirectory.ts"],
|
|
4
4
|
"sourcesContent": ["import fs from 'fs-extra';\n\n/**\n * Checks if a path is an empty directory.\n *\n * @param path The path to check.\n * @returns `true` if path is an empty directory, `false` otherwise.\n */\nexport async function isEmptyDirectory(path: string) {\n try {\n let directory = await fs.opendir(path);\n let entry = await directory.read();\n\n await directory.close();\n\n return entry === null;\n } catch {\n return false;\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,OAAO,QAAQ;AAQf,sBAAsB,iBAAiB,MAAc;AACnD,MAAI;AACF,QAAI,YAAY,MAAM,GAAG,QAAQ,IAAI;AACrC,QAAI,QAAQ,MAAM,UAAU,KAAK;AAEjC,UAAM,UAAU,MAAM;AAEtB,WAAO,UAAU;AAAA,EACnB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/isRootPath.js
CHANGED
package/build/isRootPath.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../source/isRootPath.ts"],
|
|
4
4
|
"sourcesContent": ["import path from 'node:path';\n\n/**\n * Checks if a path is a file system root path.\n *\n * @param path The path to check.\n * @returns `true` if path is the root, `false` otherwise.\n */\nexport function isRootPath(value: string) {\n return value.toLowerCase() === path.parse(value).root.toLowerCase();\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AAQV,gBAAS,WAAW,OAAe;AACxC,SAAO,MAAM,YAAY,MAAM,KAAK,MAAM,KAAK,EAAE,KAAK,YAAY;AACpE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/main.js
CHANGED
package/build/main.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../source/main.ts"],
|
|
4
4
|
"sourcesContent": ["export * from './createTempDirectory.js';\nexport * from './ensureEmptyDirectory.js';\nexport * from './findDirectories.js';\nexport * from './findExistingDirectory.js';\nexport * from './isDirectory.js';\nexport * from './isEmptyDirectory.js';\nexport * from './isRootPath.js';\nexport * from './pathToPosixPath.js';\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/pathToPosixPath.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../source/pathToPosixPath.ts"],
|
|
4
4
|
"sourcesContent": ["import path from 'node:path';\n\n/**\n * Converts path to POSIX path.\n *\n * @param value The path to convert.\n * @returns The converted path.\n */\nexport function pathToPosixPath(value: string): string {\n return value.split(path.win32.sep).join(path.posix.sep);\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AAQV,gBAAS,gBAAgB,OAAuB;AACrD,SAAO,MAAM,MAAM,KAAK,MAAM,GAAG,EAAE,KAAK,KAAK,MAAM,GAAG;AACxD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jakubmazanec/fs-utils",
|
|
3
|
-
"version": "0.2.18
|
|
3
|
+
"version": "0.2.18",
|
|
4
4
|
"description": "Collection of utilities for working with file system.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"fs-extra": "^11.3.6"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@jakubmazanec/eslint-config": "5.0.0
|
|
33
|
+
"@jakubmazanec/eslint-config": "^5.0.0",
|
|
34
34
|
"@types/fs-extra": "^11.0.4",
|
|
35
35
|
"@types/lodash": "^4.17.24",
|
|
36
36
|
"@types/node": "^24.0.4",
|
|
37
37
|
"@vitest/coverage-v8": "^4.1.10",
|
|
38
|
-
"concurrently": "^
|
|
38
|
+
"concurrently": "^10.0.3",
|
|
39
39
|
"del-cli": "^7.0.0",
|
|
40
40
|
"esbuild": "^0.28.1",
|
|
41
41
|
"eslint": "^9.39.4",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"prettier-plugin-packagejson": "^2.5.22",
|
|
45
45
|
"typedoc": "^0.28.20",
|
|
46
46
|
"typedoc-plugin-markdown": "^4.12.0",
|
|
47
|
-
"typescript": "^
|
|
47
|
+
"typescript": "^6.0.0",
|
|
48
48
|
"vitest": "^4.1.10"
|
|
49
49
|
},
|
|
50
50
|
"packageManager": "npm@11.3.0",
|