@awsless/ts-file-cache 0.0.12 → 0.0.13
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/dist/index.cjs +9 -5
- package/dist/index.js +7 -3
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -18,13 +18,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
23
|
generateFileHash: () => generateFileHash,
|
|
24
24
|
generateFolderHash: () => generateFolderHash,
|
|
25
25
|
loadWorkspace: () => loadWorkspace
|
|
26
26
|
});
|
|
27
|
-
module.exports = __toCommonJS(
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
28
|
var import_promises4 = require("fs/promises");
|
|
29
29
|
|
|
30
30
|
// src/hash.ts
|
|
@@ -131,9 +131,13 @@ var generateRecursiveFileHashes = async (workspace, file, sourceFile, allowedExt
|
|
|
131
131
|
return;
|
|
132
132
|
}
|
|
133
133
|
const code = await (0, import_promises2.readFile)(file, "utf8");
|
|
134
|
-
const
|
|
134
|
+
const ext = file.split(".").pop();
|
|
135
135
|
const hash = (0, import_crypto.createHash)("sha1").update(code).digest();
|
|
136
136
|
hashes.set(relFile, hash);
|
|
137
|
+
if (!ext || !allowedExtensions.includes(ext)) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const deps = await findImports(file, code);
|
|
137
141
|
for (const dep of deps) {
|
|
138
142
|
await generateRecursiveFileHashes(workspace, dep, file, allowedExtensions, hashes);
|
|
139
143
|
}
|
|
@@ -271,7 +275,7 @@ var generateFolderHash = async (workspace, folder, opts = {}) => {
|
|
|
271
275
|
const files = await (0, import_promises4.readdir)(folder, { recursive: true, withFileTypes: true });
|
|
272
276
|
for (const file of files) {
|
|
273
277
|
if (file.isFile() && options.extensions.includes((0, import_path5.extname)(file.name).substring(1))) {
|
|
274
|
-
const f = (0, import_path5.resolve)(file.
|
|
278
|
+
const f = (0, import_path5.resolve)(file.parentPath, file.name);
|
|
275
279
|
await generateRecursiveFileHashes(workspace, f, f, options.extensions, hashes);
|
|
276
280
|
}
|
|
277
281
|
}
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { readdir } from "fs/promises";
|
|
|
4
4
|
// src/hash.ts
|
|
5
5
|
import { createHash } from "crypto";
|
|
6
6
|
import { readFile } from "fs/promises";
|
|
7
|
-
import { builtinModules } from "
|
|
7
|
+
import { builtinModules } from "module";
|
|
8
8
|
import { relative } from "path";
|
|
9
9
|
|
|
10
10
|
// src/import.ts
|
|
@@ -105,9 +105,13 @@ var generateRecursiveFileHashes = async (workspace, file, sourceFile, allowedExt
|
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
107
|
const code = await readFile(file, "utf8");
|
|
108
|
-
const
|
|
108
|
+
const ext = file.split(".").pop();
|
|
109
109
|
const hash = createHash("sha1").update(code).digest();
|
|
110
110
|
hashes.set(relFile, hash);
|
|
111
|
+
if (!ext || !allowedExtensions.includes(ext)) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const deps = await findImports(file, code);
|
|
111
115
|
for (const dep of deps) {
|
|
112
116
|
await generateRecursiveFileHashes(workspace, dep, file, allowedExtensions, hashes);
|
|
113
117
|
}
|
|
@@ -245,7 +249,7 @@ var generateFolderHash = async (workspace, folder, opts = {}) => {
|
|
|
245
249
|
const files = await readdir(folder, { recursive: true, withFileTypes: true });
|
|
246
250
|
for (const file of files) {
|
|
247
251
|
if (file.isFile() && options.extensions.includes(extname(file.name).substring(1))) {
|
|
248
|
-
const f = resolve2(file.
|
|
252
|
+
const f = resolve2(file.parentPath, file.name);
|
|
249
253
|
await generateRecursiveFileHashes(workspace, f, f, options.extensions, hashes);
|
|
250
254
|
}
|
|
251
255
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awsless/ts-file-cache",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
21
22
|
"require": "./dist/index.cjs",
|
|
22
|
-
"import": "./dist/index.js"
|
|
23
|
-
"types": "./dist/index.d.ts"
|
|
23
|
+
"import": "./dist/index.js"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|