@markuplint/file-resolver 3.11.0 → 3.12.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/lib/config-provider.js +6 -1
- package/lib/ml-file/ml-file.d.ts +1 -0
- package/lib/ml-file/ml-file.js +19 -1
- package/package.json +16 -15
package/lib/config-provider.js
CHANGED
|
@@ -273,10 +273,15 @@ function pathResolve(dir, filePath, resolveProps, resolveKey = false) {
|
|
|
273
273
|
return res;
|
|
274
274
|
}
|
|
275
275
|
function resolve(dir, pathOrModName) {
|
|
276
|
+
var _a, _b, _c;
|
|
276
277
|
if (moduleExists(pathOrModName) || isPreset(pathOrModName) || isPlugin(pathOrModName)) {
|
|
277
278
|
return pathOrModName;
|
|
278
279
|
}
|
|
279
|
-
|
|
280
|
+
const bangAndPath = (_a = /^(!)(.*)/.exec(pathOrModName)) !== null && _a !== void 0 ? _a : [];
|
|
281
|
+
const bang = (_b = bangAndPath[1]) !== null && _b !== void 0 ? _b : '';
|
|
282
|
+
const pathname = (_c = bangAndPath[2]) !== null && _c !== void 0 ? _c : pathOrModName;
|
|
283
|
+
const absPath = path_1.default.resolve(dir, pathname);
|
|
284
|
+
return bang + absPath;
|
|
280
285
|
}
|
|
281
286
|
function moduleExists(name) {
|
|
282
287
|
try {
|
package/lib/ml-file/ml-file.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare class MLFile {
|
|
|
14
14
|
get path(): string;
|
|
15
15
|
dirExists(): Promise<boolean>;
|
|
16
16
|
getCode(): Promise<string>;
|
|
17
|
+
ignored(globPath: string | readonly string[]): boolean;
|
|
17
18
|
isExist(): Promise<boolean>;
|
|
18
19
|
isFile(): Promise<boolean>;
|
|
19
20
|
matches(globPath: string): boolean;
|
package/lib/ml-file/ml-file.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.MLFile = void 0;
|
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const fs_1 = require("fs");
|
|
7
7
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
|
+
const ignore_1 = tslib_1.__importDefault(require("ignore"));
|
|
8
9
|
const minimatch_1 = require("minimatch");
|
|
9
10
|
class MLFile {
|
|
10
11
|
constructor(target) {
|
|
@@ -67,6 +68,13 @@ class MLFile {
|
|
|
67
68
|
}
|
|
68
69
|
return '';
|
|
69
70
|
}
|
|
71
|
+
ignored(globPath) {
|
|
72
|
+
globPath = typeof globPath === 'string' ? [globPath] : globPath;
|
|
73
|
+
const normalizedPaths = globPath.map(p => pathNormalize(p, true));
|
|
74
|
+
const ig = (0, ignore_1.default)().add(normalizedPaths);
|
|
75
|
+
const ignored = ig.ignores(pathNormalize(this.nPath, true));
|
|
76
|
+
return ignored;
|
|
77
|
+
}
|
|
70
78
|
async isExist() {
|
|
71
79
|
if (tslib_1.__classPrivateFieldGet(this, _MLFile_type, "f") === 'code-base') {
|
|
72
80
|
return true;
|
|
@@ -120,12 +128,22 @@ async function stat(filePath) {
|
|
|
120
128
|
throw err;
|
|
121
129
|
}
|
|
122
130
|
}
|
|
123
|
-
function pathNormalize(filePath) {
|
|
131
|
+
function pathNormalize(filePath, relative = false) {
|
|
132
|
+
const hasBang = filePath.startsWith('!');
|
|
133
|
+
if (hasBang) {
|
|
134
|
+
filePath = filePath.slice(1);
|
|
135
|
+
}
|
|
124
136
|
// Remove the local disk scheme of Windows OS
|
|
125
137
|
if (path_1.default.isAbsolute(filePath)) {
|
|
126
138
|
filePath = filePath.replace(/^[a-z]+:/i, '');
|
|
139
|
+
if (relative) {
|
|
140
|
+
filePath = path_1.default.relative(path_1.default.sep, filePath);
|
|
141
|
+
}
|
|
127
142
|
}
|
|
128
143
|
// Replace the separator of Windows OS
|
|
129
144
|
filePath = filePath.split(path_1.default.sep).join('/');
|
|
145
|
+
if (hasBang) {
|
|
146
|
+
filePath = `!${filePath}`;
|
|
147
|
+
}
|
|
130
148
|
return filePath;
|
|
131
149
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/file-resolver",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.12.1",
|
|
4
4
|
"description": "The file resolver of markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -19,23 +19,24 @@
|
|
|
19
19
|
"clean": "tsc --build --clean"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@types/node": "20.
|
|
22
|
+
"@types/node": "20.6.0"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@markuplint/html-parser": "3.
|
|
25
|
+
"@markuplint/html-parser": "3.10.1",
|
|
26
26
|
"@markuplint/ml-ast": "3.2.0",
|
|
27
|
-
"@markuplint/ml-config": "3.
|
|
28
|
-
"@markuplint/ml-core": "3.
|
|
29
|
-
"@markuplint/ml-spec": "3.
|
|
30
|
-
"@markuplint/parser-utils": "3.
|
|
31
|
-
"@markuplint/selector": "3.
|
|
32
|
-
"@markuplint/shared": "3.
|
|
33
|
-
"cosmiconfig": "^8.
|
|
34
|
-
"cosmiconfig-typescript-loader": "^
|
|
35
|
-
"glob": "^10.
|
|
27
|
+
"@markuplint/ml-config": "3.11.1",
|
|
28
|
+
"@markuplint/ml-core": "3.12.1",
|
|
29
|
+
"@markuplint/ml-spec": "3.11.1",
|
|
30
|
+
"@markuplint/parser-utils": "3.10.1",
|
|
31
|
+
"@markuplint/selector": "3.11.1",
|
|
32
|
+
"@markuplint/shared": "3.8.0",
|
|
33
|
+
"cosmiconfig": "^8.3.5",
|
|
34
|
+
"cosmiconfig-typescript-loader": "^5.0.0",
|
|
35
|
+
"glob": "^10.3.4",
|
|
36
|
+
"ignore": "^5.2.4",
|
|
36
37
|
"jsonc": "^2.0.0",
|
|
37
|
-
"minimatch": "^9.0.
|
|
38
|
-
"tslib": "^2.
|
|
38
|
+
"minimatch": "^9.0.3",
|
|
39
|
+
"tslib": "^2.6.2"
|
|
39
40
|
},
|
|
40
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "09100b8baa14dd930602daa458197322197c79c2"
|
|
41
42
|
}
|