@zohodesk/react-cli 0.0.1-exp.166.1 → 0.0.1-exp.166.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/README.md +8 -0
- package/lib/configs/webpack.docs.config.js +2 -2
- package/lib/schemas/index.js +1 -0
- package/lib/utils/rtl.js +19 -2
- package/lib/utils/useExitCleanup.js +55 -0
- package/package.json +1 -1
package/README.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
A CLI tool for build modern web application and libraries
|
4
4
|
|
5
|
+
# 0.0.1-exp.166.2
|
6
|
+
|
7
|
+
Changes:-
|
8
|
+
|
9
|
+
- `-w` option (watch option) added for `react-cli rtl`
|
10
|
+
- Example `react-cli rtl ./src ./lib -w`
|
11
|
+
- disableES5Transpile option libAlias added for docs
|
12
|
+
|
5
13
|
# 0.0.1-exp.166.1
|
6
14
|
|
7
15
|
Changes:-
|
@@ -16,6 +16,7 @@ let options = (0, _utils.getOptions)();
|
|
16
16
|
let {
|
17
17
|
docs: {
|
18
18
|
componentFolder,
|
19
|
+
disableES5Transpile,
|
19
20
|
cssUniqueness,
|
20
21
|
hasRTL,
|
21
22
|
rtlExclude,
|
@@ -23,8 +24,7 @@ let {
|
|
23
24
|
classNamePrefix
|
24
25
|
},
|
25
26
|
app: {
|
26
|
-
folder
|
27
|
-
disableES5Transpile
|
27
|
+
folder
|
28
28
|
}
|
29
29
|
} = options;
|
30
30
|
let appPath = process.cwd();
|
package/lib/schemas/index.js
CHANGED
package/lib/utils/rtl.js
CHANGED
@@ -18,7 +18,10 @@ let src = _path.default.join(cwd, process.argv[2]);
|
|
18
18
|
|
19
19
|
let dist = _path.default.join(cwd, process.argv[3]);
|
20
20
|
|
21
|
-
|
21
|
+
let canWacth = '-w' === process.argv[4];
|
22
|
+
|
23
|
+
// import { useExitCleanup } from './useExitCleanup';
|
24
|
+
function watchHandler(fromPath, toPath) {
|
22
25
|
let css = _fs.default.readFileSync(fromPath);
|
23
26
|
|
24
27
|
(0, _postcss.default)([(0, _postcssRtl.default)({
|
@@ -39,4 +42,18 @@ let dist = _path.default.join(cwd, process.argv[3]);
|
|
39
42
|
_fs.default.writeFile(`${toPath}.map`, result.map, () => true);
|
40
43
|
}
|
41
44
|
});
|
42
|
-
}
|
45
|
+
}
|
46
|
+
|
47
|
+
(0, _folderIterator.default)(src, dist, ['.css'], false, (fromPath, toPath) => {
|
48
|
+
if (canWacth && fromPath) {
|
49
|
+
_fs.default.watchFile(fromPath, () => {
|
50
|
+
watchHandler(fromPath, toPath);
|
51
|
+
});
|
52
|
+
}
|
53
|
+
|
54
|
+
watchHandler(fromPath, toPath);
|
55
|
+
}); // if (canWacth) {
|
56
|
+
// useExitCleanup(() => {
|
57
|
+
// fs.unwatchFile(src, watchHandler);
|
58
|
+
// });
|
59
|
+
// }
|
@@ -0,0 +1,55 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.useExitCleanup = useExitCleanup;
|
7
|
+
//so the program will not close instantly
|
8
|
+
let listeners = [];
|
9
|
+
let hasCalled = false;
|
10
|
+
|
11
|
+
function useExitCleanup(listener) {
|
12
|
+
if (!hasCalled) {
|
13
|
+
process.stdin.resume();
|
14
|
+
hasCalled = true;
|
15
|
+
}
|
16
|
+
|
17
|
+
listeners.push(listeners);
|
18
|
+
return () => {
|
19
|
+
listeners = listeners.filter(l => l !== listener);
|
20
|
+
};
|
21
|
+
}
|
22
|
+
|
23
|
+
function exitHandler(options, exitCode) {
|
24
|
+
if (options.cleanup) {
|
25
|
+
console.log('clean');
|
26
|
+
}
|
27
|
+
|
28
|
+
if (exitCode || exitCode === 0) {
|
29
|
+
console.log(exitCode);
|
30
|
+
}
|
31
|
+
|
32
|
+
if (options.exit) {
|
33
|
+
process.exit();
|
34
|
+
}
|
35
|
+
} //do something when app is closing
|
36
|
+
|
37
|
+
|
38
|
+
process.on('exit', exitHandler.bind(null, {
|
39
|
+
cleanup: true
|
40
|
+
})); //catches ctrl+c event
|
41
|
+
|
42
|
+
process.on('SIGINT', exitHandler.bind(null, {
|
43
|
+
exit: true
|
44
|
+
})); // catches "kill pid" (for example: nodemon restart)
|
45
|
+
|
46
|
+
process.on('SIGUSR1', exitHandler.bind(null, {
|
47
|
+
exit: true
|
48
|
+
}));
|
49
|
+
process.on('SIGUSR2', exitHandler.bind(null, {
|
50
|
+
exit: true
|
51
|
+
})); //catches uncaught exceptions
|
52
|
+
|
53
|
+
process.on('uncaughtException', exitHandler.bind(null, {
|
54
|
+
exit: true
|
55
|
+
}));
|