sn-typescript-util 1.2.2 → 1.2.3
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/bin/snts.js +23 -23
- package/package.json +1 -1
- package/src/snts.ts +24 -24
package/bin/snts.js
CHANGED
|
@@ -21,6 +21,25 @@ async function doCompile() {
|
|
|
21
21
|
return stdout;
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
+
function doOptions(program) {
|
|
25
|
+
program.parse(process.argv).opts();
|
|
26
|
+
const option = Object.keys(program.opts()).toString();
|
|
27
|
+
const options = {
|
|
28
|
+
build: () => {
|
|
29
|
+
doBuild();
|
|
30
|
+
},
|
|
31
|
+
compile: () => {
|
|
32
|
+
doCompile();
|
|
33
|
+
},
|
|
34
|
+
sync: () => {
|
|
35
|
+
doSync();
|
|
36
|
+
},
|
|
37
|
+
default: () => {
|
|
38
|
+
program.help();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
return ((hasApplication() && options[option]) || options['default'])();
|
|
42
|
+
}
|
|
24
43
|
async function doSync() {
|
|
25
44
|
const s = startPrompts('Processing', 'Sync started');
|
|
26
45
|
return await execFile(getFilePath('sync.sh'), (stdout) => {
|
|
@@ -48,28 +67,9 @@ function getErrorMsg() {
|
|
|
48
67
|
return console.error(bold(red(msg)));
|
|
49
68
|
}
|
|
50
69
|
function getFilePath(file, dir = 'scripts') {
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
return `${path.join(
|
|
54
|
-
}
|
|
55
|
-
function getOption(program) {
|
|
56
|
-
program.parse(process.argv).opts();
|
|
57
|
-
const option = Object.keys(program.opts()).toString();
|
|
58
|
-
const options = {
|
|
59
|
-
build: () => {
|
|
60
|
-
doBuild();
|
|
61
|
-
},
|
|
62
|
-
compile: () => {
|
|
63
|
-
doCompile();
|
|
64
|
-
},
|
|
65
|
-
sync: () => {
|
|
66
|
-
doSync();
|
|
67
|
-
},
|
|
68
|
-
default: () => {
|
|
69
|
-
program.help();
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
return (options[option] || options['default'])();
|
|
70
|
+
const fileName = fileURLToPath(import.meta.url);
|
|
71
|
+
const dirName = path.dirname(fileName);
|
|
72
|
+
return `${path.join(dirName, `../${dir}`)}/${file}`;
|
|
73
73
|
}
|
|
74
74
|
async function getPackageInfo() {
|
|
75
75
|
return JSON.parse(readFileSync(getFilePath('package.json', '.')).toString());
|
|
@@ -99,7 +99,7 @@ async function init() {
|
|
|
99
99
|
program.option('-b, --build', 'build project utility files & package dependencies');
|
|
100
100
|
program.option('-c, --compile', 'compile TypeScript files to JavaScript & move to src');
|
|
101
101
|
program.option('-s, --sync', 'sync new instance-based src files to the ts directory');
|
|
102
|
-
return
|
|
102
|
+
return doOptions(program);
|
|
103
103
|
}
|
|
104
104
|
function introPrompt(msg) {
|
|
105
105
|
return intro(msg);
|
package/package.json
CHANGED
package/src/snts.ts
CHANGED
|
@@ -26,6 +26,26 @@ async function doCompile() {
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
function doOptions(program: any) {
|
|
30
|
+
program.parse(process.argv).opts();
|
|
31
|
+
const option = Object.keys(program.opts()).toString();
|
|
32
|
+
const options = {
|
|
33
|
+
build: () => {
|
|
34
|
+
doBuild();
|
|
35
|
+
},
|
|
36
|
+
compile: () => {
|
|
37
|
+
doCompile();
|
|
38
|
+
},
|
|
39
|
+
sync: () => {
|
|
40
|
+
doSync();
|
|
41
|
+
},
|
|
42
|
+
default: () => {
|
|
43
|
+
program.help();
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return ((hasApplication() && options[option]) || options['default'])();
|
|
47
|
+
}
|
|
48
|
+
|
|
29
49
|
async function doSync() {
|
|
30
50
|
const s = startPrompts('Processing', 'Sync started');
|
|
31
51
|
return await execFile(getFilePath('sync.sh'), (stdout: any) => {
|
|
@@ -55,29 +75,9 @@ function getErrorMsg() {
|
|
|
55
75
|
}
|
|
56
76
|
|
|
57
77
|
function getFilePath(file: string, dir: string = 'scripts') {
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
return `${path.join(
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function getOption(program: any) {
|
|
64
|
-
program.parse(process.argv).opts();
|
|
65
|
-
const option = Object.keys(program.opts()).toString();
|
|
66
|
-
const options = {
|
|
67
|
-
build: () => {
|
|
68
|
-
doBuild();
|
|
69
|
-
},
|
|
70
|
-
compile: () => {
|
|
71
|
-
doCompile();
|
|
72
|
-
},
|
|
73
|
-
sync: () => {
|
|
74
|
-
doSync();
|
|
75
|
-
},
|
|
76
|
-
default: () => {
|
|
77
|
-
program.help();
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
return (options[option] || options['default'])();
|
|
78
|
+
const fileName = fileURLToPath(import.meta.url);
|
|
79
|
+
const dirName = path.dirname(fileName);
|
|
80
|
+
return `${path.join(dirName, `../${dir}`)}/${file}`;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
async function getPackageInfo() {
|
|
@@ -120,7 +120,7 @@ async function init() {
|
|
|
120
120
|
'-s, --sync',
|
|
121
121
|
'sync new instance-based src files to the ts directory'
|
|
122
122
|
);
|
|
123
|
-
return
|
|
123
|
+
return doOptions(program);
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
function introPrompt(msg: string) {
|