@granite-js/utils 0.1.6 → 0.1.8
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 +4 -0
- package/dist/index.cjs +18 -0
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +16 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
ensureSafetyInvokeSync: () => ensureSafetyInvokeSync,
|
|
34
|
+
getLocalTempDirectoryPath: () => getLocalTempDirectoryPath,
|
|
34
35
|
getPackageRoot: () => getPackageRoot,
|
|
36
|
+
prepareLocalDirectory: () => prepareLocalDirectory,
|
|
35
37
|
readZipContent: () => readZipContent,
|
|
36
38
|
readZipEntries: () => readZipEntries
|
|
37
39
|
});
|
|
@@ -151,10 +153,26 @@ function ensureSafetyInvokeSync(fn) {
|
|
|
151
153
|
}
|
|
152
154
|
};
|
|
153
155
|
}
|
|
156
|
+
|
|
157
|
+
// src/localTempDirectory.ts
|
|
158
|
+
var import_fs2 = __toESM(require("fs"), 1);
|
|
159
|
+
var import_path2 = __toESM(require("path"), 1);
|
|
160
|
+
function getLocalTempDirectoryPath(rootDir) {
|
|
161
|
+
return import_path2.default.resolve(rootDir, ".granite");
|
|
162
|
+
}
|
|
163
|
+
function prepareLocalDirectory(rootDir) {
|
|
164
|
+
const localDir = getLocalTempDirectoryPath(rootDir);
|
|
165
|
+
if (!import_fs2.default.existsSync(localDir)) {
|
|
166
|
+
import_fs2.default.mkdirSync(localDir, { recursive: true });
|
|
167
|
+
}
|
|
168
|
+
return localDir;
|
|
169
|
+
}
|
|
154
170
|
// Annotate the CommonJS export names for ESM import in node:
|
|
155
171
|
0 && (module.exports = {
|
|
156
172
|
ensureSafetyInvokeSync,
|
|
173
|
+
getLocalTempDirectoryPath,
|
|
157
174
|
getPackageRoot,
|
|
175
|
+
prepareLocalDirectory,
|
|
158
176
|
readZipContent,
|
|
159
177
|
readZipEntries
|
|
160
178
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -6,4 +6,7 @@ declare function readZipEntries(zipPath: string): Promise<Record<string, string>
|
|
|
6
6
|
type Fn<T> = (...args: any[]) => T;
|
|
7
7
|
declare function ensureSafetyInvokeSync<T>(fn: Fn<T>): Fn<T | null>;
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
declare function getLocalTempDirectoryPath(rootDir: string): string;
|
|
10
|
+
declare function prepareLocalDirectory(rootDir: string): string;
|
|
11
|
+
|
|
12
|
+
export { ensureSafetyInvokeSync, getLocalTempDirectoryPath, getPackageRoot, prepareLocalDirectory, readZipContent, readZipEntries };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,4 +6,7 @@ declare function readZipEntries(zipPath: string): Promise<Record<string, string>
|
|
|
6
6
|
type Fn<T> = (...args: any[]) => T;
|
|
7
7
|
declare function ensureSafetyInvokeSync<T>(fn: Fn<T>): Fn<T | null>;
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
declare function getLocalTempDirectoryPath(rootDir: string): string;
|
|
10
|
+
declare function prepareLocalDirectory(rootDir: string): string;
|
|
11
|
+
|
|
12
|
+
export { ensureSafetyInvokeSync, getLocalTempDirectoryPath, getPackageRoot, prepareLocalDirectory, readZipContent, readZipEntries };
|
package/dist/index.js
CHANGED
|
@@ -112,9 +112,25 @@ function ensureSafetyInvokeSync(fn) {
|
|
|
112
112
|
}
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
+
|
|
116
|
+
// src/localTempDirectory.ts
|
|
117
|
+
import fs2 from "fs";
|
|
118
|
+
import path2 from "path";
|
|
119
|
+
function getLocalTempDirectoryPath(rootDir) {
|
|
120
|
+
return path2.resolve(rootDir, ".granite");
|
|
121
|
+
}
|
|
122
|
+
function prepareLocalDirectory(rootDir) {
|
|
123
|
+
const localDir = getLocalTempDirectoryPath(rootDir);
|
|
124
|
+
if (!fs2.existsSync(localDir)) {
|
|
125
|
+
fs2.mkdirSync(localDir, { recursive: true });
|
|
126
|
+
}
|
|
127
|
+
return localDir;
|
|
128
|
+
}
|
|
115
129
|
export {
|
|
116
130
|
ensureSafetyInvokeSync,
|
|
131
|
+
getLocalTempDirectoryPath,
|
|
117
132
|
getPackageRoot,
|
|
133
|
+
prepareLocalDirectory,
|
|
118
134
|
readZipContent,
|
|
119
135
|
readZipEntries
|
|
120
136
|
};
|