@jakubmazanec/fs-utils 0.2.17 → 0.2.18-unstable.1b6e18dc
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../source/ensureEmptyDirectory.ts"],
|
|
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]
|
|
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,
|
|
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": ";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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jakubmazanec/fs-utils",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.18-unstable.1b6e18dc",
|
|
4
4
|
"description": "Collection of utilities for working with file system.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"fs-extra": "^11.3.2"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@jakubmazanec/eslint-config": "
|
|
33
|
+
"@jakubmazanec/eslint-config": "5.0.0-unstable.1b6e18dc",
|
|
34
34
|
"@types/fs-extra": "^11.0.4",
|
|
35
35
|
"@types/lodash": "^4.17.21",
|
|
36
36
|
"@types/node": "^24.0.4",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"concurrently": "^9.2.1",
|
|
39
39
|
"del-cli": "^7.0.0",
|
|
40
40
|
"esbuild": "^0.27.0",
|
|
41
|
-
"eslint": "^9.
|
|
41
|
+
"eslint": "^9.39.4",
|
|
42
42
|
"lodash": "^4.17.21",
|
|
43
43
|
"prettier": "^3.7.3",
|
|
44
44
|
"prettier-plugin-packagejson": "^2.5.20",
|
|
@@ -37,7 +37,7 @@ export async function ensureEmptyDirectory(
|
|
|
37
37
|
throw new Error(`Directory "${targetPath}" can contain only ".git" directory.`);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
if (!(await fs.stat(path.join(targetPath, files[0]
|
|
40
|
+
if (!(await fs.stat(path.join(targetPath, files[0]))).isDirectory()) {
|
|
41
41
|
throw new Error(`Directory "${targetPath}" can contain only ".git" directory.`);
|
|
42
42
|
}
|
|
43
43
|
}
|