@needle-tools/needle-component-compiler 1.9.1 → 1.9.2-exp

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/src/watcher.js ADDED
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.DirectoryWatcher = void 0;
4
+ var fs = require("fs");
5
+ var base_compiler_1 = require("./base-compiler");
6
+ var blender_compiler_1 = require("./blender-compiler");
7
+ var chokidar = require("chokidar");
8
+ var commands_1 = require("./commands");
9
+ // https://github.com/paulmillr/chokidar
10
+ var DirectoryWatcher = /** @class */ (function () {
11
+ function DirectoryWatcher() {
12
+ this.compiler = new base_compiler_1.Compiler();
13
+ this._needReload = false;
14
+ }
15
+ DirectoryWatcher.prototype.startWatching = function (dir, writer) {
16
+ var _this = this;
17
+ // console.log("Start watching", dir);
18
+ chokidar.watch(dir + "/**/*.ts").on('all', function (event, path) {
19
+ try {
20
+ switch (event) {
21
+ case "add":
22
+ console.log("File", path, "has been added");
23
+ break;
24
+ case "change":
25
+ console.log("File", path, "has been changed");
26
+ _this.compiler.compile(writer, fs.readFileSync(path).toString());
27
+ _this._needReload = true;
28
+ break;
29
+ case "unlink":
30
+ console.log("File", path, "has been removed");
31
+ break;
32
+ default:
33
+ console.log("File unhandled event", event, path);
34
+ }
35
+ }
36
+ catch (err) {
37
+ console.error(err);
38
+ }
39
+ });
40
+ // call reload cmd
41
+ setInterval(function () {
42
+ if (_this._needReload) {
43
+ _this._needReload = false;
44
+ (0, commands_1.sendReloadCommand)();
45
+ }
46
+ }, 2000);
47
+ };
48
+ return DirectoryWatcher;
49
+ }());
50
+ exports.DirectoryWatcher = DirectoryWatcher;
51
+ // listen to process exit
52
+ process.on('exit', function () {
53
+ console.log('Bye node');
54
+ });
55
+ var args = process.argv.slice(2);
56
+ if (args.length < 2) {
57
+ console.error("Missing arguments, usage: node watcher.js <directory> <output>");
58
+ process.exit(1);
59
+ }
60
+ var directoryToWatch = args[0].replace("\"", "");
61
+ var outputDirectory = args[1].replace("\"", "");
62
+ console.log("Watch: " + directoryToWatch + " and output to: " + outputDirectory);
63
+ var watcher = new DirectoryWatcher();
64
+ watcher.startWatching(directoryToWatch, new blender_compiler_1.BlenderWriter(outputDirectory));
package/COMPILE.bat DELETED
@@ -1 +0,0 @@
1
- npm run tsc src/component-compiler
package/DEV.bat DELETED
@@ -1 +0,0 @@
1
- npm install && npm run dev
package/INSTALL.bat DELETED
@@ -1 +0,0 @@
1
- npm install && timeout 10
package/PUBLISH.bat DELETED
@@ -1,8 +0,0 @@
1
- @echo off
2
- echo Press a key to publish! (close the window if you changed your mind)
3
- pause
4
- echo Publishing in 2 sec
5
- timeout 2
6
- npm run compile & npm set registry https://registry.npmjs.org && npm publish & pause
7
- echo Finished...
8
- timeout 10
@@ -1 +0,0 @@
1
- npm run tsc src/component-compiler && node src/component-compiler.js dist src/test.ts
package/RUN_TESTS.bat DELETED
@@ -1 +0,0 @@
1
- npm run test & pause