paralayer 1.0.0 → 1.0.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/paralayer.d.ts +1 -0
- package/dist/paralayer.js +10 -4
- package/package.json +1 -1
package/dist/paralayer.d.ts
CHANGED
package/dist/paralayer.js
CHANGED
|
@@ -109,12 +109,12 @@ export class Paralayer extends $utils.Unit {
|
|
|
109
109
|
const layerFile = $path.join(this.options.output, `layer.${layer}.ts`);
|
|
110
110
|
const layerPaths = pathsByLayers[layer].toSorted();
|
|
111
111
|
const layerContent = this.generateLayerContent(layer, layerPaths);
|
|
112
|
-
await
|
|
112
|
+
await this.write(layerFile, layerContent);
|
|
113
113
|
// Top layer? -> Generate index.[layer].ts
|
|
114
114
|
if (this.isTopLayer(layer)) {
|
|
115
115
|
const indexFile = $path.join(this.options.output, `index.${layer}.ts`);
|
|
116
116
|
const indexContent = this.generateIndexContent(layer, allLayers);
|
|
117
|
-
await
|
|
117
|
+
await this.write(indexFile, indexContent);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
// Determine removed layers
|
|
@@ -134,7 +134,7 @@ export class Paralayer extends $utils.Unit {
|
|
|
134
134
|
// Generate setup.js file
|
|
135
135
|
const setupFile = $path.join(this.options.output, 'setup.js');
|
|
136
136
|
const setupContent = this.generateSetupContent(allLayers);
|
|
137
|
-
await
|
|
137
|
+
await this.write(setupFile, setupContent);
|
|
138
138
|
}
|
|
139
139
|
// ---------------------------------------------------------------------------
|
|
140
140
|
// HELPERS
|
|
@@ -148,7 +148,7 @@ export class Paralayer extends $utils.Unit {
|
|
|
148
148
|
generateLayerContent(layer, layerPaths) {
|
|
149
149
|
const $LayerName = this.getLayerName(layer, '$Pascal');
|
|
150
150
|
const $layerName = this.getLayerName(layer, '$camel');
|
|
151
|
-
const allNames = layerPaths.flatMap(path => this.files[path]
|
|
151
|
+
const allNames = layerPaths.flatMap(path => this.files[path]?.names ?? []);
|
|
152
152
|
const imports = layerPaths
|
|
153
153
|
.map(path => {
|
|
154
154
|
const file = this.files[path];
|
|
@@ -234,4 +234,10 @@ export class Paralayer extends $utils.Unit {
|
|
|
234
234
|
isTopLayer(layer) {
|
|
235
235
|
return !layer.includes('.');
|
|
236
236
|
}
|
|
237
|
+
async write(path, content) {
|
|
238
|
+
const [prevContent] = await $utils.safe(() => $fs.readFile(path, 'utf-8'));
|
|
239
|
+
if (content === prevContent)
|
|
240
|
+
return;
|
|
241
|
+
await $fs.writeFile(path, content, 'utf-8');
|
|
242
|
+
}
|
|
237
243
|
}
|