@needle-tools/needle-component-compiler 3.0.0-alpha.5 → 3.0.0-alpha.6
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/base-compiler.d.ts +2 -0
- package/dist/base-compiler.js +14 -0
- package/package.json +1 -1
package/dist/base-compiler.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export interface ISink {
|
|
|
15
15
|
}
|
|
16
16
|
export declare class FileSink implements ISink {
|
|
17
17
|
private directory;
|
|
18
|
+
private static readonly CODEGEN_START;
|
|
19
|
+
private static readonly CODEGEN_END;
|
|
18
20
|
constructor(directory: string);
|
|
19
21
|
flush(id: string, str: string): string;
|
|
20
22
|
}
|
package/dist/base-compiler.js
CHANGED
|
@@ -21,9 +21,23 @@ var FileSink = /** @class */ (function () {
|
|
|
21
21
|
}
|
|
22
22
|
console.log("Writing " + id + " to " + this.directory);
|
|
23
23
|
var fullPath = this.directory + "/" + id;
|
|
24
|
+
// If the file already exists and contains codegen fences,
|
|
25
|
+
// preserve content outside the fences
|
|
26
|
+
if (fs.existsSync(fullPath)) {
|
|
27
|
+
var existing = fs.readFileSync(fullPath, "utf-8");
|
|
28
|
+
var startIdx = existing.indexOf(FileSink.CODEGEN_START);
|
|
29
|
+
var endIdx = existing.indexOf(FileSink.CODEGEN_END);
|
|
30
|
+
if (startIdx !== -1 && endIdx !== -1) {
|
|
31
|
+
var before_1 = existing.substring(0, startIdx);
|
|
32
|
+
var after_1 = existing.substring(endIdx + FileSink.CODEGEN_END.length);
|
|
33
|
+
str = before_1 + str + after_1;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
24
36
|
fs.writeFileSync(fullPath, str);
|
|
25
37
|
return fs.realpathSync(fullPath);
|
|
26
38
|
};
|
|
39
|
+
FileSink.CODEGEN_START = "// NEEDLE_CODEGEN_START";
|
|
40
|
+
FileSink.CODEGEN_END = "// NEEDLE_CODEGEN_END";
|
|
27
41
|
return FileSink;
|
|
28
42
|
}());
|
|
29
43
|
exports.FileSink = FileSink;
|