@jakubmazanec/fs-utils 0.2.19-unstable.72f063e3 → 0.2.19

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,6 +1,5 @@
1
1
  /**
2
- * Creates a unique temporary directory in the operating system's default directory for temporary
3
- * files. The name of the directory is random, but can be prefixed with a custom string.
2
+ * 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.
4
3
  *
5
4
  * @param prefix The new directory name prefix.
6
5
  * @returns The new directory name.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../source/createTempDirectory.ts"],
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\n * 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": "AAAA,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AASjB,sBAAsB,oBAAoB,QAAiB;AACzD,SAAO,GAAG,QAAQ,KAAK,KAAK,GAAG,OAAO,GAAG,UAAU,GAAG,CAAC;AACzD;",
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": "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
  }
@@ -6,8 +6,7 @@ export type EnsureEmptyDirectoryOptions = {
6
6
  allowGit?: boolean | undefined;
7
7
  };
8
8
  /**
9
- * Ensures that a path is actually an empty directory. If the path doesn't exist, the directory is
10
- * created; if the path exists but isn't an ampty directory, error is thrown.
9
+ * 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.
11
10
  *
12
11
  * @param path The target path.
13
12
  */
@@ -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\n * 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;AAgB/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;",
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
  }
@@ -1,6 +1,5 @@
1
1
  /**
2
- * Travels up the file system tree from a starting path and returns path of the first existing
3
- * directory.
2
+ * Travels up the file system tree from a starting path and returns path of the first existing directory.
4
3
  *
5
4
  * ```TypeScript
6
5
  * let result = findExistingDirectory('/foo/bar/baz'); // if there is no `bar` directory, `result` is `'/foo'`
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../source/findExistingDirectory.ts"],
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\n * 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": "AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAEjB,SAAQ,mBAAkB;AAY1B,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;",
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": "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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jakubmazanec/fs-utils",
3
- "version": "0.2.19-unstable.72f063e3",
3
+ "version": "0.2.19",
4
4
  "description": "Collection of utilities for working with file system.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,9 +17,9 @@
17
17
  "source"
18
18
  ],
19
19
  "scripts": {
20
- "build": "del-cli build tsconfig.tsbuildinfo && esbuild \"source/**/*\" --platform=node --target=node24.3 --outdir=build --sourcemap && tsc",
20
+ "build": "del-cli build tsconfig.tsbuildinfo && esbuild \"source/**/*\" --platform=node --target=node24.21 --outdir=build --sourcemap && tsc",
21
21
  "clean": "del-cli coverage build *.tsbuildinfo",
22
- "develop": "concurrently \"esbuild \"source/**/*\" --platform=node --target=node24.3 --outdir=build --sourcemap --watch\" \"tsc --watch\"",
22
+ "develop": "concurrently \"esbuild \"source/**/*\" --platform=node --target=node24.21 --outdir=build --sourcemap --watch\" \"tsc --watch\"",
23
23
  "document": "del-cli docs && typedoc --options typedoc.config.cjs",
24
24
  "format": "prettier . --write --ignore-unknown",
25
25
  "lint": "eslint .",
@@ -27,29 +27,29 @@
27
27
  "typecheck": "tsc --project tsconfig.typecheck.json"
28
28
  },
29
29
  "dependencies": {
30
- "fs-extra": "^11.3.6"
30
+ "fs-extra": "^11.4.1"
31
31
  },
32
32
  "devDependencies": {
33
- "@jakubmazanec/eslint-config": "6.0.0-unstable.72f063e3",
33
+ "@jakubmazanec/eslint-config": "^5.0.0",
34
34
  "@types/fs-extra": "^11.0.4",
35
- "@types/lodash": "^4.17.24",
36
- "@types/node": "^24.0.4",
37
- "@vitest/coverage-v8": "^4.1.10",
38
- "concurrently": "^10.0.3",
35
+ "@types/lodash": "^4.17.25",
36
+ "@types/node": "^24.19.1",
37
+ "@vitest/coverage-v8": "^4.1.11",
38
+ "concurrently": "^10.0.6",
39
39
  "del-cli": "^7.0.0",
40
- "esbuild": "^0.28.1",
41
- "eslint": "^9.39.4",
40
+ "esbuild": "^0.28.2",
41
+ "eslint": "^9.39.5",
42
42
  "lodash": "^4.18.1",
43
- "prettier": "^3.9.5",
43
+ "prettier": "^3.9.9",
44
44
  "prettier-plugin-packagejson": "^2.5.22",
45
45
  "typedoc": "^0.28.20",
46
- "typedoc-plugin-markdown": "^4.12.0",
47
- "typescript": "^6.0.0",
48
- "vitest": "^4.1.10"
46
+ "typedoc-plugin-markdown": "^4.13.1",
47
+ "typescript": "^6.0.3",
48
+ "vitest": "^4.1.11"
49
49
  },
50
- "packageManager": "npm@11.3.0",
50
+ "packageManager": "npm@11.21.0",
51
51
  "engines": {
52
- "node": "^24.3.0",
53
- "npm": "^11.3.0"
52
+ "node": "^24.21.0",
53
+ "npm": "^11.21.0"
54
54
  }
55
55
  }
@@ -3,8 +3,7 @@ import os from 'node:os';
3
3
  import path from 'node:path';
4
4
 
5
5
  /**
6
- * Creates a unique temporary directory in the operating system's default directory for temporary
7
- * files. The name of the directory is random, but can be prefixed with a custom string.
6
+ * 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.
8
7
  *
9
8
  * @param prefix The new directory name prefix.
10
9
  * @returns The new directory name.
@@ -12,8 +12,7 @@ export type EnsureEmptyDirectoryOptions = {
12
12
  };
13
13
 
14
14
  /**
15
- * Ensures that a path is actually an empty directory. If the path doesn't exist, the directory is
16
- * created; if the path exists but isn't an ampty directory, error is thrown.
15
+ * 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.
17
16
  *
18
17
  * @param path The target path.
19
18
  */
@@ -4,8 +4,7 @@ import path from 'node:path';
4
4
  import {isDirectory} from './isDirectory.js';
5
5
 
6
6
  /**
7
- * Travels up the file system tree from a starting path and returns path of the first existing
8
- * directory.
7
+ * Travels up the file system tree from a starting path and returns path of the first existing directory.
9
8
  *
10
9
  * ```TypeScript
11
10
  * let result = findExistingDirectory('/foo/bar/baz'); // if there is no `bar` directory, `result` is `'/foo'`