tshtml-loader 1.1.6 → 1.1.7
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/lib/export-template.d.ts +1 -0
- package/lib/export-template.js +25 -3
- package/package.json +2 -1
package/lib/export-template.d.ts
CHANGED
package/lib/export-template.js
CHANGED
|
@@ -1,20 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
"use strict";
|
|
2
3
|
exports.__esModule = true;
|
|
3
4
|
var fs_1 = require("fs");
|
|
4
5
|
var path = require("node:path");
|
|
5
6
|
var index_1 = require("./index");
|
|
7
|
+
// ----------------------------------------------------------------------------------
|
|
6
8
|
if (process.argv.length !== 3) {
|
|
7
9
|
console.error("Please specify one .tshtml file");
|
|
8
10
|
process.exit();
|
|
9
11
|
}
|
|
10
12
|
var fileName = process.argv[2];
|
|
13
|
+
var extension = path.extname(fileName).toLowerCase();
|
|
14
|
+
if (extension !== ".tshtml") {
|
|
15
|
+
console.error("Input file must have .tshtml extension");
|
|
16
|
+
process.exit();
|
|
17
|
+
}
|
|
18
|
+
var fileNameNoExtension = fileName.substr(0, fileName.length - extension.length);
|
|
19
|
+
var outputFileName = fileNameNoExtension + ".html";
|
|
11
20
|
fs_1.readFile(fileName, { encoding: 'utf-8' }, function (err, data) {
|
|
12
21
|
if (!err) {
|
|
13
|
-
|
|
22
|
+
// Transform the source
|
|
23
|
+
var result = index_1.executeTemplate(data, path.join(process.cwd(), "/test.html"));
|
|
14
24
|
var htmlResult = index_1.templateToString(result.exports["default"]);
|
|
15
|
-
|
|
25
|
+
// Write to destination
|
|
26
|
+
// process.stdout.write( htmlResult );
|
|
27
|
+
fs_1.writeFile(outputFileName, htmlResult, {
|
|
28
|
+
encoding: "utf8",
|
|
29
|
+
flag: "w"
|
|
30
|
+
}, function (writeErr) {
|
|
31
|
+
if (!writeErr) {
|
|
32
|
+
console.log("File is written: " + outputFileName);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
console.log("Error writing to the output file " + outputFileName, writeErr);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
16
38
|
}
|
|
17
39
|
else {
|
|
18
|
-
console.log(err);
|
|
40
|
+
console.log("Error reading the input file " + fileName, err);
|
|
19
41
|
}
|
|
20
42
|
});
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tshtml-loader",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"lib/*.*"
|
|
8
8
|
],
|
|
9
|
+
"bin": "./lib/export-template.js",
|
|
9
10
|
"scripts": {
|
|
10
11
|
"build": "tsc ./src/index.ts ./src/export-template.ts --outdir ./lib -d",
|
|
11
12
|
"build-watch": "tsc ./src/index.ts --outdir ./lib -d -w"
|