@mobilabs/es6lib 1.1.0 → 1.1.1

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.
@@ -1,5 +1,5 @@
1
1
  /*! ****************************************************************************
2
- * ES6lib v1.1.0
2
+ * ES6lib v1.1.1
3
3
  *
4
4
  * A template for writing pure ES6 Javascript libraries.
5
5
  * (you can download it from npm or github repositories)
@@ -312,14 +312,14 @@
312
312
  const obj = Object.create(methods);
313
313
  obj._library = {
314
314
  name: 'ES6lib',
315
- version: '1.1.0',
315
+ version: '1.1.1',
316
316
  };
317
317
  return obj;
318
318
  };
319
319
 
320
320
  // Attaches constants to ES6lib that provide name and version of the lib.
321
321
  ES6lib.NAME = 'ES6lib';
322
- ES6lib.VERSION = '1.1.0';
322
+ ES6lib.VERSION = '1.1.1';
323
323
 
324
324
 
325
325
  // -- Private Static Methods -----------------------------------------------
@@ -1,5 +1,5 @@
1
1
  /*! ****************************************************************************
2
- * ES6lib v1.1.0
2
+ * ES6lib v1.1.1
3
3
  *
4
4
  * A template for writing pure ES6 Javascript libraries.
5
5
  * (you can download it from npm or github repositories)
@@ -8,4 +8,4 @@
8
8
  * at: http://www.opensource.org/licenses/mit-license.php).
9
9
  * Built from {{boiler:name}} v{{boiler:name:version}}.
10
10
  * ************************************************************************** */
11
- !function(t,e){"use strict";"function"==typeof define&&define.amd?define([""],e):"object"==typeof exports?module.exports=e(t):t.ES6lib=e(t)}(this,(t=>{"use strict";let e,n;const i={Public:{}};return n=function(t,e){const n=Object.keys(e);for(let i=0;i<n.length;i++)t[n[i]]=e[n[i]]},function(){const t=i.Public;n(t,{getString:()=>"I am a string!",getArray:()=>[1,2,3]})}(),function(){const n=i.Public,r=t.ES6lib;let o;e=function(){const t=Object.create(o);return t._library={name:"ES6lib",version:"1.1.0"},t},e.NAME="ES6lib",e.VERSION="1.1.0",e._setTestMode=function(){return[]},e.noConflict=function(){return t.ES6lib=r,this},o={whoami(){return this._library},getString:()=>n.getString(),getArray:()=>n.getArray()}}(),e}));
11
+ !function(t,e){"use strict";"function"==typeof define&&define.amd?define([""],e):"object"==typeof exports?module.exports=e(t):t.ES6lib=e(t)}(this,(t=>{"use strict";let e,n;const i={Public:{}};return n=function(t,e){const n=Object.keys(e);for(let i=0;i<n.length;i++)t[n[i]]=e[n[i]]},function(){const t=i.Public;n(t,{getString:()=>"I am a string!",getArray:()=>[1,2,3]})}(),function(){const n=i.Public,r=t.ES6lib;let o;e=function(){const t=Object.create(o);return t._library={name:"ES6lib",version:"1.1.1"},t},e.NAME="ES6lib",e.VERSION="1.1.1",e._setTestMode=function(){return[]},e.noConflict=function(){return t.ES6lib=r,this},o={whoami(){return this._library},getString:()=>n.getString(),getArray:()=>n.getArray()}}(),e}));
@@ -1,5 +1,5 @@
1
1
  /*! ****************************************************************************
2
- * ES6lib v1.1.0
2
+ * ES6lib v1.1.1
3
3
  *
4
4
  * A template for writing pure ES6 Javascript libraries.
5
5
  * (you can download it from npm or github repositories)
@@ -8,4 +8,4 @@
8
8
  * at: http://www.opensource.org/licenses/mit-license.php).
9
9
  * Built from {{boiler:name}} v{{boiler:name:version}}.
10
10
  * ************************************************************************** */
11
- const $__ES6GLOB={};!function(t,e){"use strict";"function"==typeof define&&define.amd?define([""],e):"object"==typeof exports?module.exports=e(t):t.ES6lib=e(t)}($__ES6GLOB,(t=>{"use strict";let e,n;const i={Public:{}};return n=function(t,e){const n=Object.keys(e);for(let i=0;i<n.length;i++)t[n[i]]=e[n[i]]},function(){const t=i.Public;n(t,{getString:()=>"I am a string!",getArray:()=>[1,2,3]})}(),function(){const n=i.Public,r=t.ES6lib;let o;e=function(){const t=Object.create(o);return t._library={name:"ES6lib",version:"1.1.0"},t},e.NAME="ES6lib",e.VERSION="1.1.0",e._setTestMode=function(){return[]},e.noConflict=function(){return t.ES6lib=r,this},o={whoami(){return this._library},getString:()=>n.getString(),getArray:()=>n.getArray()}}(),e}));export default $__ES6GLOB.ES6lib;
11
+ const $__ES6GLOB={};!function(t,e){"use strict";"function"==typeof define&&define.amd?define([""],e):"object"==typeof exports?module.exports=e(t):t.ES6lib=e(t)}($__ES6GLOB,(t=>{"use strict";let e,n;const i={Public:{}};return n=function(t,e){const n=Object.keys(e);for(let i=0;i<n.length;i++)t[n[i]]=e[n[i]]},function(){const t=i.Public;n(t,{getString:()=>"I am a string!",getArray:()=>[1,2,3]})}(),function(){const n=i.Public,r=t.ES6lib;let o;e=function(){const t=Object.create(o);return t._library={name:"ES6lib",version:"1.1.1"},t},e.NAME="ES6lib",e.VERSION="1.1.1",e._setTestMode=function(){return[]},e.noConflict=function(){return t.ES6lib=r,this},o={whoami(){return this._library},getString:()=>n.getString(),getArray:()=>n.getArray()}}(),e}));export default $__ES6GLOB.ES6lib;
@@ -1,5 +1,5 @@
1
1
  /*! ****************************************************************************
2
- * ES6lib v1.1.0
2
+ * ES6lib v1.1.1
3
3
  *
4
4
  * A template for writing pure ES6 Javascript libraries.
5
5
  * (you can download it from npm or github repositories)
@@ -313,14 +313,14 @@ const $__ES6GLOB = {};
313
313
  const obj = Object.create(methods);
314
314
  obj._library = {
315
315
  name: 'ES6lib',
316
- version: '1.1.0',
316
+ version: '1.1.1',
317
317
  };
318
318
  return obj;
319
319
  };
320
320
 
321
321
  // Attaches constants to ES6lib that provide name and version of the lib.
322
322
  ES6lib.NAME = 'ES6lib';
323
- ES6lib.VERSION = '1.1.0';
323
+ ES6lib.VERSION = '1.1.1';
324
324
 
325
325
 
326
326
  // -- Private Static Methods -----------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mobilabs/es6lib",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "A template for writing pure ES6 Javascript libraries",
5
5
  "main": "index.js",
6
6
  "minified": "_dist/lib/es6lib.min.js",
@@ -0,0 +1,247 @@
1
+ #!/usr/bin/env node
2
+ /* *****************************************************************************
3
+ *
4
+ * Does ...
5
+ *
6
+ * build:template script is a framework to build npm build scripts;
7
+ *
8
+ * Private Functions:
9
+ * . _help displays the help message,
10
+ * . _clean removes the previous build,
11
+ * . _dosomething creates something,
12
+ *
13
+ *
14
+ * Public Static Methods:
15
+ * . run executes the script,
16
+ *
17
+ *
18
+ * @namespace -
19
+ * @dependencies none
20
+ * @exports -
21
+ * @author -
22
+ * @since 0.0.0
23
+ * @version -
24
+ * ************************************************************************** */
25
+ /* eslint one-var: 0, semi-style: 0, no-underscore-dangle: 0,
26
+ import/no-extraneous-dependencies: 0 */
27
+
28
+ 'use strict';
29
+
30
+ // -- Vendor Modules
31
+ const fs = require('fs')
32
+ , nopt = require('nopt')
33
+ ;
34
+
35
+
36
+ // -- Local Modules
37
+ const config = require('./config')
38
+ ;
39
+
40
+
41
+ // -- Local Constants
42
+ const VERSION = '0.0.0-alpha.0'
43
+ , opts = {
44
+ help: [Boolean, false],
45
+ version: [String, null],
46
+ }
47
+ , shortOpts = {
48
+ h: ['--help'],
49
+ v: ['--version', VERSION],
50
+ }
51
+ , parsed = nopt(opts, shortOpts, process.argv, 2)
52
+ , destination = config.libdir
53
+ ;
54
+
55
+
56
+ // -- Local Variables
57
+
58
+
59
+ // -- Private Functions --------------------------------------------------------
60
+
61
+ /**
62
+ * Dispays the help message.
63
+ *
64
+ * @function ()
65
+ * @private
66
+ * @param {} -,
67
+ * @returns {} -,
68
+ * @since 0.0.0
69
+ */
70
+ function _help() {
71
+ const message = ['',
72
+ 'Usage: command [options]',
73
+ '',
74
+ ' creates something from something',
75
+ '',
76
+ 'Options:',
77
+ '',
78
+ '-h, --help output usage information',
79
+ '-v, --version output the version number',
80
+ '',
81
+ ].join('\n');
82
+
83
+ process.stdout.write(`${message}\n`);
84
+ }
85
+
86
+ /**
87
+ * Removes the previous build.
88
+ *
89
+ * @function ()
90
+ * @private
91
+ * @param {} -,
92
+ * @returns {Object} returns a promise,
93
+ * @since 0.0.0
94
+ */
95
+ function _clean() {
96
+ const d1 = new Date();
97
+ process.stdout.write('Starting \'\x1b[36mclean\x1b[89m\x1b[0m\'...\n');
98
+
99
+ return new Promise((resolve) => {
100
+ fs.rm(destination, { force: true, recursive: true }, (err1) => {
101
+ if (err1) throw new Error(err1);
102
+
103
+ fs.mkdir(destination, { recursive: true }, (err2) => {
104
+ if (err2) throw new Error(err2);
105
+
106
+ const d2 = new Date() - d1;
107
+ process.stdout.write(`Finished '\x1b[36mclean\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
108
+ resolve();
109
+ });
110
+ });
111
+ });
112
+ }
113
+
114
+ /**
115
+ * Creates something else.
116
+ *
117
+ * @function (arg1)
118
+ * @private
119
+ * @param {Function} the function to call at the completion,
120
+ * @returns {} -,
121
+ * @since 0.0.0
122
+ */
123
+ function _doparallel1(done) {
124
+ const d1 = new Date();
125
+ process.stdout.write('Starting \'\x1b[36mdoparallel1\x1b[89m\x1b[0m\'...\n');
126
+
127
+ fs.writeFile(`${destination}/generic1.js`, 'bla bla', { encoding: 'utf8' }, (err) => {
128
+ if (err) throw new Error(err);
129
+
130
+ const d2 = new Date() - d1;
131
+ process.stdout.write(`Finished '\x1b[36mdodoparallel1\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
132
+ done();
133
+ });
134
+ }
135
+
136
+ /**
137
+ * Creates something else.
138
+ *
139
+ * @function (arg1)
140
+ * @private
141
+ * @param {Function} the function to call at the completion,
142
+ * @returns {} -,
143
+ * @since 0.0.0
144
+ */
145
+ function _doparallel2(done) {
146
+ const d1 = new Date();
147
+ process.stdout.write('Starting \'\x1b[36mdoparallel2\x1b[89m\x1b[0m\'...\n');
148
+
149
+ fs.writeFile(`${destination}/generic2.js`, 'bla bla', { encoding: 'utf8' }, (err) => {
150
+ if (err) throw new Error(err);
151
+
152
+ const d2 = new Date() - d1;
153
+ process.stdout.write(`Finished '\x1b[36mdodoparallel2\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
154
+ done();
155
+ });
156
+ }
157
+
158
+ /**
159
+ * Removes the temp file(s).
160
+ *
161
+ * @function (arg1)
162
+ * @private
163
+ * @param {Function} the function to call at the completion,
164
+ * @returns {} -,
165
+ * @since 0.0.0
166
+ */
167
+ function _delgeneric(done) {
168
+ const d1 = new Date();
169
+ process.stdout.write('Starting \'\x1b[36mdelgeneric\x1b[89m\x1b[0m\'...\n');
170
+
171
+ /**
172
+ * Wait all the processes are completed.
173
+ */
174
+ let pending = 2;
175
+ function _next() {
176
+ pending -= 1;
177
+ if (!pending) {
178
+ const d2 = new Date() - d1;
179
+ process.stdout.write(`Finished '\x1b[36mdelgeneric\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
180
+ done();
181
+ }
182
+ }
183
+
184
+ fs.unlink(`${destination}/generic1.js`, (err) => {
185
+ if (err) throw new Error(err);
186
+ _next();
187
+ });
188
+
189
+ fs.unlink(`${destination}/generic2.js`, (err) => {
190
+ if (err) throw new Error(err);
191
+ _next();
192
+ });
193
+ }
194
+
195
+
196
+ // -- Main ---------------------------------------------------------------------
197
+
198
+ /**
199
+ * Executes the script.
200
+ *
201
+ * @function ()
202
+ * @puublic
203
+ * @param {} -,
204
+ * @returns {} -,
205
+ * @since 0.0.0
206
+ */
207
+ async function run() {
208
+ const PENDING = 2;
209
+
210
+ if (parsed.help) {
211
+ _help();
212
+ return;
213
+ }
214
+
215
+ if (parsed.version) {
216
+ process.stdout.write(`version: ${parsed.version}\n`);
217
+ return;
218
+ }
219
+
220
+ const d1 = new Date();
221
+ process.stdout.write('Starting \'\x1b[36mbuild:js:dev\x1b[89m\x1b[0m\'...\n');
222
+
223
+ let pending = PENDING;
224
+ /**
225
+ * Executes done until completion.
226
+ */
227
+ function done() {
228
+ pending -= 1;
229
+ if (!pending) {
230
+ _delgeneric(() => {
231
+ const d2 = new Date() - d1;
232
+ process.stdout.write(`Finished '\x1b[36mbuild:js:dev\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
233
+ });
234
+ }
235
+ }
236
+
237
+ await _clean();
238
+ _doparallel1(done);
239
+ _doparallel2(done);
240
+ }
241
+
242
+
243
+ // Start script.
244
+ run();
245
+
246
+
247
+ // -- oOo --
@@ -12,7 +12,7 @@
12
12
  * . _docore creates the content of the library,
13
13
  * . _doumdlib creates the UMD Module,
14
14
  * . _domodule creates the ES6 module,
15
- * . _delgeneric removes the temp file(s),
15
+ * . _delcore removes the temp file(s),
16
16
  *
17
17
  *
18
18
  * Public Static Methods:
@@ -93,7 +93,6 @@ function _help() {
93
93
  ].join('\n');
94
94
 
95
95
  process.stdout.write(`${message}\n`);
96
- process.exit(0);
97
96
  }
98
97
 
99
98
  /**
@@ -119,7 +118,7 @@ function _clean() {
119
118
  /**
120
119
  * Creates the content of the library.
121
120
  *
122
- * @function (arg1)
121
+ * @function ()
123
122
  * @private
124
123
  * @param {} -,
125
124
  * @returns {} -,
@@ -253,7 +252,7 @@ function _delcore() {
253
252
  * @returns {} -,
254
253
  * @since 0.0.0
255
254
  */
256
- async function run() {
255
+ function run() {
257
256
  if (parsed.help) {
258
257
  _help();
259
258
  return;
@@ -89,7 +89,6 @@ function _help() {
89
89
  ].join('\n');
90
90
 
91
91
  process.stdout.write(`${message}\n`);
92
- process.exit(0);
93
92
  }
94
93
 
95
94
  /**
@@ -105,11 +104,19 @@ function _clean() {
105
104
  const d1 = new Date();
106
105
  process.stdout.write('Starting \'\x1b[36mclean\x1b[89m\x1b[0m\'...\n');
107
106
 
108
- fs.rmSync(`${dist}/lib`, { force: true, recursive: true });
109
- fs.mkdirSync(`${dist}/lib`, { recursive: true });
107
+ return new Promise((resolve) => {
108
+ fs.rm(`${dist}/lib`, { force: true, recursive: true }, (err1) => {
109
+ if (err1) throw new Error(err1);
110
110
 
111
- const d2 = new Date() - d1;
112
- process.stdout.write(`Finished '\x1b[36mclean\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
111
+ fs.mkdir(`${dist}/lib`, { recursive: true }, (err2) => {
112
+ if (err2) throw new Error(err2);
113
+
114
+ const d2 = new Date() - d1;
115
+ process.stdout.write(`Finished '\x1b[36mclean\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
116
+ resolve();
117
+ });
118
+ });
119
+ });
113
120
  }
114
121
 
115
122
  /**
@@ -244,11 +251,12 @@ function _makeminifiedm(done) {
244
251
  * @returns {} -,
245
252
  * @since 0.0.0
246
253
  */
247
- function run() {
254
+ async function run() {
248
255
  const PENDING = 4;
249
256
 
250
257
  if (parsed.help) {
251
258
  _help();
259
+ return;
252
260
  }
253
261
 
254
262
  if (parsed.version) {
@@ -271,7 +279,7 @@ function run() {
271
279
  }
272
280
  }
273
281
 
274
- _clean();
282
+ await _clean();
275
283
  _copydev(done);
276
284
  _copydevm(done);
277
285
  _makeminified(done);
@@ -84,7 +84,6 @@ function _help() {
84
84
  ].join('\n');
85
85
 
86
86
  process.stdout.write(`${message}\n`);
87
- process.exit(0);
88
87
  }
89
88
 
90
89
  /**
@@ -93,17 +92,22 @@ function _help() {
93
92
  * @function ()
94
93
  * @private
95
94
  * @param {} -,
96
- * @returns {} -,
95
+ * @returns {Object} returns a promise,
97
96
  * @since 0.0.0
98
97
  */
99
98
  function _clean() {
100
99
  const d1 = new Date();
101
100
  process.stdout.write('Starting \'\x1b[36mclean\x1b[89m\x1b[0m\'...\n');
102
101
 
103
- fs.rmSync(dist, { force: true, recursive: true });
102
+ return new Promise((resolve) => {
103
+ fs.rm(dist, { force: true, recursive: true }, (err) => {
104
+ if (err) throw new Error(err);
104
105
 
105
- const d2 = new Date() - d1;
106
- process.stdout.write(`Finished '\x1b[36mclean\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
106
+ const d2 = new Date() - d1;
107
+ process.stdout.write(`Finished '\x1b[36mclean\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
108
+ resolve();
109
+ });
110
+ });
107
111
  }
108
112
 
109
113
  /**
@@ -119,15 +123,25 @@ function _doskeleton(done) {
119
123
  const d1 = new Date();
120
124
  process.stdout.write('Starting \'\x1b[36mdoskeleton\x1b[89m\x1b[0m\'...\n');
121
125
 
126
+ /**
127
+ * Wait all processes completed;
128
+ */
129
+ let pending = webfiles.length;
130
+ function _next() {
131
+ pending -= 1;
132
+ if (!pending) {
133
+ const d2 = new Date() - d1;
134
+ process.stdout.write(`Finished '\x1b[36mdoskeleton\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
135
+ done();
136
+ }
137
+ }
138
+
122
139
  let filename;
123
140
  for (let i = 0; i < webfiles.length; i++) {
124
141
  filename = path.basename(webfiles[i]);
125
142
  fs.cp(webfiles[i], `${dist}/${filename}`, (err) => {
126
143
  if (err) throw new Error(err);
127
-
128
- const d2 = new Date() - d1;
129
- process.stdout.write(`Finished '\x1b[36mdoskeleton\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
130
- done();
144
+ _next();
131
145
  });
132
146
  }
133
147
  }
@@ -144,11 +158,12 @@ function _doskeleton(done) {
144
158
  * @returns {} -,
145
159
  * @since 0.0.0
146
160
  */
147
- function run() {
161
+ async function run() {
148
162
  const PENDING = 1;
149
163
 
150
164
  if (parsed.help) {
151
165
  _help();
166
+ return;
152
167
  }
153
168
 
154
169
  if (parsed.version) {
@@ -171,7 +186,7 @@ function run() {
171
186
  }
172
187
  }
173
188
 
174
- _clean();
189
+ await _clean();
175
190
  _doskeleton(done);
176
191
  }
177
192
 
@@ -1,10 +1,38 @@
1
- /* eslint one-var: 0, import/no-extraneous-dependencies: 0, semi-style: 0 */
1
+ #!/usr/bin/env node
2
+ /* *****************************************************************************
3
+ *
4
+ * Creates a private npm package.
5
+ *
6
+ * dep:private script creates a npm package not to be published but used
7
+ * locally.
8
+ *
9
+ * Private Functions:
10
+ * . _help displays the help message,
11
+ * . _clean removes the previous build,
12
+ * . _copyindex copies the modified index,
13
+ * . _copypackagejson copies the modified package.json,
14
+ *
15
+ *
16
+ * Public Static Methods:
17
+ * . run executes the script,
18
+ *
19
+ *
20
+ * @namespace -
21
+ * @dependencies none
22
+ * @exports -
23
+ * @author -
24
+ * @since 0.0.0
25
+ * @version -
26
+ * ************************************************************************** */
27
+ /* eslint one-var: 0, semi-style: 0, no-underscore-dangle: 0,
28
+ import/no-extraneous-dependencies: 0 */
2
29
 
3
30
  'use strict';
4
31
 
5
32
  // -- Vendor Modules
6
33
  const fs = require('fs')
7
34
  , path = require('path')
35
+ , nopt = require('nopt')
8
36
  ;
9
37
 
10
38
 
@@ -14,7 +42,17 @@ const config = require('./config')
14
42
 
15
43
 
16
44
  // -- Local Constants
17
- const tmppriv = './private_repo/tmp'
45
+ const VERSION = '0.0.0-alpha.0'
46
+ , opts = {
47
+ help: [Boolean, false],
48
+ version: [String, null],
49
+ }
50
+ , shortOpts = {
51
+ h: ['--help'],
52
+ v: ['--version', VERSION],
53
+ }
54
+ , parsed = nopt(opts, shortOpts, process.argv, 2)
55
+ , tmppriv = './private_repo/tmp'
18
56
  , { name } = config
19
57
  , { index } = config
20
58
  , { distlink } = config
@@ -24,76 +62,171 @@ const tmppriv = './private_repo/tmp'
24
62
  // -- Local Variables
25
63
 
26
64
 
27
- // -- Private Tasks
65
+ // -- Private Functions --------------------------------------------------------
28
66
 
29
67
  /**
30
- * Removes the previous version.
68
+ * Dispays the help message.
69
+ *
70
+ * @function ()
71
+ * @private
72
+ * @param {} -,
73
+ * @returns {} -,
74
+ * @since 0.0.0
31
75
  */
32
- function clear() {
76
+ function _help() {
77
+ const message = ['',
78
+ 'Usage: command [options]',
79
+ '',
80
+ ' creates a private npm package to be used locally',
81
+ '',
82
+ 'Options:',
83
+ '',
84
+ '-h, --help output usage information',
85
+ '-v, --version output the version number',
86
+ '',
87
+ ].join('\n');
88
+
89
+ process.stdout.write(`${message}\n`);
90
+ }
91
+
92
+ /**
93
+ * Removes the previous build.
94
+ *
95
+ * @function ()
96
+ * @private
97
+ * @param {} -,
98
+ * @returns {Object} returns a promise,
99
+ * @since 0.0.0
100
+ */
101
+ function _clean() {
33
102
  const d1 = new Date();
34
- process.stdout.write('Starting \'\x1b[36mclear\x1b[89m\x1b[0m\'...\n');
103
+ process.stdout.write('Starting \'\x1b[36mclean\x1b[89m\x1b[0m\'...\n');
35
104
 
105
+ return new Promise((resolve) => {
106
+ fs.rm(tmppriv, { force: true, recursive: true }, (err1) => {
107
+ if (err1) throw new Error(err1);
36
108
 
37
- fs.rmSync(tmppriv, { force: true, recursive: true });
38
- fs.mkdirSync(tmppriv, { recursive: true });
109
+ fs.mkdir(tmppriv, { recursive: true }, (err2) => {
110
+ if (err2) throw new Error(err2);
39
111
 
40
- const d2 = new Date() - d1;
41
- process.stdout.write(`Finished '\x1b[36mclear\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
112
+ const d2 = new Date() - d1;
113
+ process.stdout.write(`Finished '\x1b[36mclean\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
114
+ resolve();
115
+ });
116
+ });
117
+ });
42
118
  }
43
119
 
44
-
45
120
  /**
46
121
  * Copies the modified index.
122
+ *
123
+ * @function (arg1)
124
+ * @private
125
+ * @param {Function} the function to call at the completion,
126
+ * @returns {} -,
127
+ * @since 0.0.0
47
128
  */
48
- function copyindex() {
129
+ function _copyindex(done) {
49
130
  const d1 = new Date();
50
131
  process.stdout.write('Starting \'\x1b[36mcopyindex\x1b[89m\x1b[0m\'...\n');
51
132
 
52
- let f = fs.readFileSync(index, 'utf-8');
53
- f = f.replace(`./lib/${name}`, distlink);
133
+ fs.readFile(index, 'utf8', (err1, data) => {
134
+ if (err1) throw new Error(err1);
54
135
 
55
- const filename = path.basename(index);
56
- fs.writeFileSync(`${tmppriv}/${filename}`, f);
57
- const d2 = new Date() - d1;
58
- process.stdout.write(`Finished '\x1b[36mcopyindex\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
59
- }
136
+ const content = data.replace(`./lib/${name}`, distlink);
137
+ fs.writeFile(`${tmppriv}/${path.basename(index)}`, content, { encoding: 'utf8' }, (err2) => {
138
+ if (err2) throw new Error(err2);
60
139
 
140
+ const d2 = new Date() - d1;
141
+ process.stdout.write(`Finished '\x1b[36mcopyindex\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
142
+ done();
143
+ });
144
+ });
145
+ }
61
146
 
62
147
  /**
63
- * Copies the modified package.json
148
+ * Copies the modified package.json.
149
+ *
150
+ * @function (arg1)
151
+ * @private
152
+ * @param {Function} the function to call at the completion,
153
+ * @returns {} -,
154
+ * @since 0.0.0
64
155
  */
65
- function copypackagejson() {
156
+ function _copypackagejson(done) {
66
157
  const d1 = new Date();
67
158
  process.stdout.write('Starting \'\x1b[36mcopypackagejson\x1b[89m\x1b[0m\'...\n');
68
159
 
69
- const json = fs.readFileSync('./package.json', 'utf8');
70
- const obj = JSON.parse(json);
160
+ fs.readFile('./package.json', 'utf8', (err1, data) => {
161
+ if (err1) throw new Error(err1);
162
+
163
+ const obj = JSON.parse(data);
164
+ obj.main = distlink;
165
+ obj.bin = {};
166
+ obj.scripts = {};
167
+ obj.dependencies = {};
168
+ obj.devDependencies = {};
169
+ obj.private = true;
170
+ obj.husky = {};
171
+
172
+ fs.writeFile(`${tmppriv}/package.json`, JSON.stringify(obj, null, 2), { encooding: 'utf8' }, (err2) => {
173
+ if (err2) throw new Error(err2);
174
+
175
+ const d2 = new Date() - d1;
176
+ process.stdout.write(`Finished '\x1b[36mcopypackagejson\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
177
+ done();
178
+ });
179
+ });
180
+ }
71
181
 
72
- obj.main = distlink;
73
- obj.bin = {};
74
- obj.scripts = {};
75
- obj.dependencies = {};
76
- obj.devDependencies = {};
77
- obj.private = true;
78
- obj.husky = {};
79
182
 
80
- fs.writeFileSync(`${tmppriv}/package.json`, JSON.stringify(obj, null, 2), 'utf8');
183
+ // -- Main ---------------------------------------------------------------------
81
184
 
82
- const d2 = new Date() - d1;
83
- process.stdout.write(`Finished '\x1b[36mcopypackagejson\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
84
- }
185
+ /**
186
+ * Executes the script.
187
+ *
188
+ * @function ()
189
+ * @puublic
190
+ * @param {} -,
191
+ * @returns {} -,
192
+ * @since 0.0.0
193
+ */
194
+ async function run() {
195
+ const PENDING = 2;
85
196
 
197
+ if (parsed.help) {
198
+ _help();
199
+ return;
200
+ }
86
201
 
87
- // -- Public Task(s)
88
- const d1 = new Date();
89
- process.stdout.write('Starting \'\x1b[36mdep:private\x1b[89m\x1b[0m\'...\n');
202
+ if (parsed.version) {
203
+ process.stdout.write(`version: ${parsed.version}\n`);
204
+ return;
205
+ }
206
+
207
+ const d1 = new Date();
208
+ process.stdout.write('Starting \'\x1b[36mdep:private\x1b[89m\x1b[0m\'...\n');
209
+
210
+ let pending = PENDING;
211
+ /**
212
+ * Executes done until completion.
213
+ */
214
+ function done() {
215
+ pending -= 1;
216
+ if (!pending) {
217
+ const d2 = new Date() - d1;
218
+ process.stdout.write(`Finished '\x1b[36mdep:private\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
219
+ }
220
+ }
221
+
222
+ await _clean();
223
+ _copyindex(done);
224
+ _copypackagejson(done);
225
+ }
90
226
 
91
- clear();
92
- copyindex();
93
- copypackagejson();
94
227
 
95
- const d2 = new Date() - d1;
96
- process.stdout.write(`Finished '\x1b[36mdep:private\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
228
+ // Start script.
229
+ run();
97
230
 
98
231
 
99
232
  // -- oOo --