kerria 0.4.1 → 0.4.2
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.d.mts +1 -1
- package/dist/index.mjs +7 -9
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -46,7 +46,7 @@ interface KerriaContext {
|
|
|
46
46
|
declare function useCurrentContext(): KerriaContext;
|
|
47
47
|
declare function createKerria(sign: string, setup: (ctx: KerriaContext) => void): {
|
|
48
48
|
build: () => Promise<void>;
|
|
49
|
-
watch: () => () => void
|
|
49
|
+
watch: () => () => Promise<void[]>;
|
|
50
50
|
};
|
|
51
51
|
//#endregion
|
|
52
52
|
export { KerriaContext, LoadInfo, SourceInfo, UseLoadOptions, UseSourceOptions, createKerria, useCurrentContext, useLoad, useSource };
|
package/dist/index.mjs
CHANGED
|
@@ -46,7 +46,7 @@ function createKerria(sign, setup) {
|
|
|
46
46
|
currentContext = null;
|
|
47
47
|
ctx.sourceInfos.sort((a, b) => a.kind - b.kind);
|
|
48
48
|
const cachePath = join(pkg.cache("kerria", { create: true }), `${sign}.json`);
|
|
49
|
-
const caches = existsSync(cachePath)
|
|
49
|
+
const caches = existsSync(cachePath) ? readJsonSync(cachePath) : {};
|
|
50
50
|
async function build() {
|
|
51
51
|
for (const info of ctx.sourceInfos) {
|
|
52
52
|
const paths = await glob(info.patterns, { absolute: true });
|
|
@@ -85,9 +85,7 @@ function createKerria(sign, setup) {
|
|
|
85
85
|
consola.success(`[${sign}] Change "${info.src}"`);
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
return () =>
|
|
89
|
-
for (const watcher of watchers) watcher.close();
|
|
90
|
-
};
|
|
88
|
+
return () => Promise.all(watchers.map((watcher) => watcher.close()));
|
|
91
89
|
}
|
|
92
90
|
async function parse(path, info) {
|
|
93
91
|
const stats = await stat(path);
|
|
@@ -108,9 +106,9 @@ function createKerria(sign, setup) {
|
|
|
108
106
|
} else unlink(path, info);
|
|
109
107
|
return true;
|
|
110
108
|
}
|
|
111
|
-
|
|
112
|
-
if (caches
|
|
113
|
-
return
|
|
109
|
+
function add(path, info) {
|
|
110
|
+
if (path in caches) return false;
|
|
111
|
+
return parse(path, info);
|
|
114
112
|
}
|
|
115
113
|
function unlink(path, info) {
|
|
116
114
|
const cache = caches[path];
|
|
@@ -173,8 +171,8 @@ function useSource(kind, options) {
|
|
|
173
171
|
filter(path) {
|
|
174
172
|
return skip < path.split("/").length - folders[0].split("/").length;
|
|
175
173
|
},
|
|
176
|
-
|
|
177
|
-
|
|
174
|
+
output(path, data) {
|
|
175
|
+
return writeJson(path.replace(base, dist).replace(info.ext, ".json"), data);
|
|
178
176
|
}
|
|
179
177
|
};
|
|
180
178
|
ctx.sourceInfos.push(info);
|