fs-realpath-native 1.0.1
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/CHANGELOG.md +12 -0
- package/README.md +12 -0
- package/index.d.ts +17 -0
- package/index.js +27 -0
- package/index.js.map +1 -0
- package/jest.config.js +116 -0
- package/package.json +66 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## 1.0.1 (2022-10-18)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### 📦 Code Refactoring
|
|
11
|
+
|
|
12
|
+
* { realpathSync => realpathSync.native } ([252c33e](https://github.com/bluelovers/ws-iconv/commit/252c33eff4a210e243ce6d8c4a968ad12bb1fbaf))
|
package/README.md
ADDED
package/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { BufferEncodingOption, EncodingOption, PathLike, realpathSync } from 'fs';
|
|
4
|
+
export declare const fsRealpathNativeSync: typeof realpathSync.native;
|
|
5
|
+
export declare function fsRealpathNativeAsync(path: PathLike, options?: EncodingOption): Promise<string>;
|
|
6
|
+
export declare function fsRealpathNativeAsync(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
|
|
7
|
+
export declare function fsRealpathNativeAsync(path: PathLike, options?: EncodingOption): Promise<string | Buffer>;
|
|
8
|
+
/**
|
|
9
|
+
* @see https://github.com/facebook/jest/blob/main/packages/jest-util/src/tryRealpath.ts
|
|
10
|
+
*/
|
|
11
|
+
export declare function tryFsRealpathNativeSync(path: PathLike, options?: EncodingOption): string;
|
|
12
|
+
export declare function tryFsRealpathNativeSync(path: PathLike, options: BufferEncodingOption): Buffer;
|
|
13
|
+
export declare function tryFsRealpathNativeSync(path: PathLike, options?: EncodingOption): string | Buffer;
|
|
14
|
+
export declare function tryFsRealpathNativeAsync(path: PathLike, options?: EncodingOption): Promise<string>;
|
|
15
|
+
export declare function tryFsRealpathNativeAsync(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
|
|
16
|
+
export declare function tryFsRealpathNativeAsync(path: PathLike, options?: EncodingOption): Promise<string | Buffer>;
|
|
17
|
+
export default tryFsRealpathNativeSync;
|
package/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tryFsRealpathNativeAsync = exports.tryFsRealpathNativeSync = exports.fsRealpathNativeAsync = exports.fsRealpathNativeSync = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
exports.fsRealpathNativeSync = fs_1.realpathSync.native;
|
|
6
|
+
async function fsRealpathNativeAsync(path, options) {
|
|
7
|
+
return (0, exports.fsRealpathNativeSync)(path, options);
|
|
8
|
+
}
|
|
9
|
+
exports.fsRealpathNativeAsync = fsRealpathNativeAsync;
|
|
10
|
+
function tryFsRealpathNativeSync(path, options) {
|
|
11
|
+
try {
|
|
12
|
+
path = fs_1.realpathSync.native(path, options);
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
if (error.code !== 'ENOENT') {
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return path;
|
|
20
|
+
}
|
|
21
|
+
exports.tryFsRealpathNativeSync = tryFsRealpathNativeSync;
|
|
22
|
+
async function tryFsRealpathNativeAsync(path, options) {
|
|
23
|
+
return tryFsRealpathNativeSync(path, options);
|
|
24
|
+
}
|
|
25
|
+
exports.tryFsRealpathNativeAsync = tryFsRealpathNativeAsync;
|
|
26
|
+
exports.default = tryFsRealpathNativeSync;
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,2BAAkF;AAErE,QAAA,oBAAoB,GAAG,iBAAY,CAAC,MAAM,CAAC;AAKjD,KAAK,UAAU,qBAAqB,CAAC,IAAc,EACzD,OAA+C;IAG/C,OAAO,IAAA,4BAAoB,EAAC,IAAI,EAAE,OAAc,CAAC,CAAA;AAClD,CAAC;AALD,sDAKC;AAQD,SAAgB,uBAAuB,CAAC,IAAc,EAAE,OAA+C;IAEtG,IACA;QACC,IAAI,GAAG,iBAAY,CAAC,MAAM,CAAC,IAAI,EAAE,OAAc,CAAC,CAAC;KACjD;IACD,OAAO,KAAU,EACjB;QACC,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAC3B;YACC,MAAM,KAAK,CAAC;SACZ;KACD;IAED,OAAO,IAAW,CAAC;AACpB,CAAC;AAfD,0DAeC;AAKM,KAAK,UAAU,wBAAwB,CAAC,IAAc,EAAE,OAA+C;IAE7G,OAAO,uBAAuB,CAAC,IAAI,EAAE,OAAc,CAAC,CAAA;AACrD,CAAC;AAHD,4DAGC;AAED,kBAAe,uBAAuB,CAAA","sourcesContent":["import { BufferEncodingOption, EncodingOption, PathLike, realpathSync } from 'fs';\n\nexport const fsRealpathNativeSync = realpathSync.native;\n\nexport async function fsRealpathNativeAsync(path: PathLike, options?: EncodingOption): Promise<string>;\nexport async function fsRealpathNativeAsync(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;\nexport async function fsRealpathNativeAsync(path: PathLike, options?: EncodingOption): Promise<string | Buffer>;\nexport async function fsRealpathNativeAsync(path: PathLike,\n\toptions?: BufferEncodingOption | EncodingOption\n): Promise<string | Buffer>\n{\n\treturn fsRealpathNativeSync(path, options as any)\n}\n\n/**\n * @see https://github.com/facebook/jest/blob/main/packages/jest-util/src/tryRealpath.ts\n */\nexport function tryFsRealpathNativeSync(path: PathLike, options?: EncodingOption): string;\nexport function tryFsRealpathNativeSync(path: PathLike, options: BufferEncodingOption): Buffer;\nexport function tryFsRealpathNativeSync(path: PathLike, options?: EncodingOption): string | Buffer;\nexport function tryFsRealpathNativeSync(path: PathLike, options?: BufferEncodingOption | EncodingOption): string | Buffer\n{\n\ttry\n\t{\n\t\tpath = realpathSync.native(path, options as any);\n\t}\n\tcatch (error: any)\n\t{\n\t\tif (error.code !== 'ENOENT')\n\t\t{\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\treturn path as any;\n}\n\nexport async function tryFsRealpathNativeAsync(path: PathLike, options?: EncodingOption): Promise<string>;\nexport async function tryFsRealpathNativeAsync(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;\nexport async function tryFsRealpathNativeAsync(path: PathLike, options?: EncodingOption): Promise<string | Buffer>;\nexport async function tryFsRealpathNativeAsync(path: PathLike, options?: BufferEncodingOption | EncodingOption): Promise<string | Buffer>\n{\n\treturn tryFsRealpathNativeSync(path, options as any)\n}\n\nexport default tryFsRealpathNativeSync\n"]}
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
const { basename, extname, dirname } = require('path');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* // @type { import('@jest/types').Config.InitialOptions }
|
|
7
|
+
* @type { import('ts-jest').InitialOptionsTsJest }
|
|
8
|
+
*/
|
|
9
|
+
let jestConfig = {
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {string} name
|
|
15
|
+
* @returns {string}
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
function _requireResolve(name)
|
|
19
|
+
{
|
|
20
|
+
let result;
|
|
21
|
+
|
|
22
|
+
try
|
|
23
|
+
{
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
const { requireResolveExtra, requireResolveCore } = require('@yarn-tool/require-resolve');
|
|
26
|
+
|
|
27
|
+
const paths = [
|
|
28
|
+
requireResolveExtra('@bluelovers/tsdx').result,
|
|
29
|
+
requireResolveExtra('tsdx').result,
|
|
30
|
+
].filter(Boolean);
|
|
31
|
+
|
|
32
|
+
result = requireResolveCore(name, {
|
|
33
|
+
includeGlobal: true,
|
|
34
|
+
includeCurrentDirectory: true,
|
|
35
|
+
paths,
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
catch (e)
|
|
39
|
+
{
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
result = result || require.resolve(name);
|
|
44
|
+
|
|
45
|
+
console.info('[require.resolve]', name, '=>', result)
|
|
46
|
+
|
|
47
|
+
return result
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let _ok = true;
|
|
51
|
+
|
|
52
|
+
try
|
|
53
|
+
{
|
|
54
|
+
if (!jestConfig.preset)
|
|
55
|
+
{
|
|
56
|
+
|
|
57
|
+
let result = require('@yarn-tool/ws-find-up-paths').findUpPathsWorkspaces([
|
|
58
|
+
'jest-preset.js',
|
|
59
|
+
'jest.config.js',
|
|
60
|
+
], {
|
|
61
|
+
ignoreCurrentPackage: true,
|
|
62
|
+
onlyFiles: true,
|
|
63
|
+
}).result;
|
|
64
|
+
|
|
65
|
+
if (result)
|
|
66
|
+
{
|
|
67
|
+
let name = basename(result, extname(result))
|
|
68
|
+
|
|
69
|
+
switch (name)
|
|
70
|
+
{
|
|
71
|
+
case 'jest-preset':
|
|
72
|
+
jestConfig.preset = dirname(result);
|
|
73
|
+
break;
|
|
74
|
+
default:
|
|
75
|
+
jestConfig = {
|
|
76
|
+
...require(result),
|
|
77
|
+
jestConfig,
|
|
78
|
+
};
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
_ok = false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (e)
|
|
87
|
+
{
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
try
|
|
92
|
+
{
|
|
93
|
+
if (_ok && !jestConfig.preset)
|
|
94
|
+
{
|
|
95
|
+
let result = _requireResolve('@bluelovers/jest-config/package.json');
|
|
96
|
+
if (result)
|
|
97
|
+
{
|
|
98
|
+
jestConfig.preset = dirname(result);
|
|
99
|
+
_ok = false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch (e)
|
|
104
|
+
{
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (_ok && !jestConfig.preset)
|
|
109
|
+
{
|
|
110
|
+
jestConfig.preset = '@bluelovers/jest-config';
|
|
111
|
+
_ok = false;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
console.info(`jest.config.preset: ${jestConfig.preset}`);
|
|
115
|
+
|
|
116
|
+
module.exports = jestConfig
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "fs-realpath-native",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"create-by-yarn-tool"
|
|
7
|
+
],
|
|
8
|
+
"homepage": "https://github.com/bluelovers/ws-iconv/tree/master/packages/fs-realpath#readme",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/bluelovers/ws-iconv/issues"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/bluelovers/ws-iconv.git",
|
|
15
|
+
"directory": "packages/fs-realpath"
|
|
16
|
+
},
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"author": "bluelovers",
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"main": "jest.config.js",
|
|
21
|
+
"directories": {
|
|
22
|
+
"test": "test"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"review": "yarn run review:coverage",
|
|
26
|
+
"review:coverage": "yarn run lint && yarn run coverage",
|
|
27
|
+
"review:test": "yarn run lint && yarn run test",
|
|
28
|
+
"coverage": "yarn run test -- --coverage",
|
|
29
|
+
"lint": "yarn run lint:eslint",
|
|
30
|
+
"lint:eslint": "ynpx eslint --ext .ts,.tsx,.mts,.cts ./",
|
|
31
|
+
"pretest": "echo pretest",
|
|
32
|
+
"test": "jest --passWithNoTests",
|
|
33
|
+
"test:jest": "jest --passWithNoTests",
|
|
34
|
+
"test:jest:snapshot": "yarn run test:jest -- -u",
|
|
35
|
+
"test:mocha": "ynpx --quiet -p ts-node -p mocha mocha -- --require ts-node/register \"!(node_modules)/**/*.{test,spec}.{ts,tsx}\"",
|
|
36
|
+
"test:snapshot": "yarn run test -- -u",
|
|
37
|
+
"test:tsd": "ynpx tsd",
|
|
38
|
+
"test:tsdx": "ynpx @bluelovers/tsdx test --passWithNoTests",
|
|
39
|
+
"build:dts:bundle": "ynpx dts-bundle-generator -o ./dist/index.d.ts ./src/index.ts --no-banner --inline-declare-global & echo build:dts:bundle",
|
|
40
|
+
"build:dts:copy": "copy .\\src\\index.d.ts .\\dist\\index.d.ts & echo build:dts",
|
|
41
|
+
"build:dts:tsc": "yarn run build:dts:tsc:emit && yarn run build:dts:copy",
|
|
42
|
+
"build:dts:tsc:emit": "tsc --emitDeclarationOnly --declaration --noEmit false",
|
|
43
|
+
"build:microbundle": "ynpx microbundle --target node",
|
|
44
|
+
"build:tsdx": "ynpx @bluelovers/tsdx build --target node --name index",
|
|
45
|
+
"ci:install": "echo ci:install",
|
|
46
|
+
"ci:build": "echo ci:build",
|
|
47
|
+
"preversion": "echo preversion && yarn run test",
|
|
48
|
+
"version": "echo version",
|
|
49
|
+
"postversion": "echo postversion",
|
|
50
|
+
"prepublish": "echo prepublish",
|
|
51
|
+
"prepare": "echo prepare",
|
|
52
|
+
"prepublishOnly": "echo prepublishOnly",
|
|
53
|
+
"prepublishOnly:update": "yarn run ncu && yarn run sort-package-json",
|
|
54
|
+
"prepack": "echo prepack",
|
|
55
|
+
"pack": "echo pack",
|
|
56
|
+
"postpack": "echo postpack",
|
|
57
|
+
"publish": "echo publish",
|
|
58
|
+
"postpublish": "echo postpublish",
|
|
59
|
+
"postpublishOnly": "echo postpublishOnly",
|
|
60
|
+
"ncu": "yarn-tool ncu -u",
|
|
61
|
+
"sort-package-json": "yarn-tool sort",
|
|
62
|
+
"tsc:showConfig": "ynpx get-current-tsconfig -p"
|
|
63
|
+
},
|
|
64
|
+
"packageManager": "yarn@1.22.19",
|
|
65
|
+
"gitHead": "e6dea90eaa22e331d180711d3ec4c4d430fce071"
|
|
66
|
+
}
|