binhend 1.5.9 → 1.5.11

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,18 +1,18 @@
1
1
 
2
2
  const path = require('path');
3
3
  const fs = require('fs');
4
+ const cwdJoin = require('../utils/cwdJoin');
4
5
 
5
6
  module.exports = (args) => {
6
7
  try {
7
- var currentDirectory = process.cwd(), // directory path where the command is executed
8
- destinationPath = path.join(currentDirectory, args[0] || 'frontend'),
9
- sourcePath = path.join(__dirname, '../templates/frontend');
8
+ var destinationPath = cwdJoin(args[0] || 'frontend'),
9
+ sourcePath = path.join(__dirname, '../templates/frontend');
10
10
 
11
- console.log('[BINHEND][CODEGEN] Generate front-end structure:', destinationPath);
11
+ console.log('[BINHEND][CLI] Generate front-end structure:', destinationPath);
12
12
  fs.cpSync(sourcePath, destinationPath, {recursive: true});
13
13
  }
14
14
  catch (error) {
15
- console.error('[BINHEND][CODEGEN] Error generating front-end structure!');
15
+ console.error('[BINHEND][CLI] Error generating front-end structure!');
16
16
  throw error;
17
17
  }
18
18
  };
@@ -0,0 +1,8 @@
1
+
2
+ const runCommand = require('../utils/cmdRun');
3
+ const cwdJoin = require('../utils/cwdJoin');
4
+
5
+ module.exports = (args) => {
6
+ var scriptPath = cwdJoin(args.shift() || './', 'server.js');
7
+ runCommand('node', [scriptPath].concat(args));
8
+ };
package/bin/index.js CHANGED
@@ -1,14 +1,15 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  const commandMap = {
4
4
  create: {
5
5
  backend: () => require('./commands/create-backend'),
6
6
  frontend: () => require('./commands/create-frontend'),
7
- }
7
+ },
8
+ start: () => require('./commands/start-server'),
8
9
  };
9
10
 
10
11
  var command = commandMap,
11
- args = process.argv.slice(2); // remove first 2 args in list: <path-to-nodejs> and <path-to-this-CLI-program-file>
12
+ args = process.argv.slice(2); // remove first 2 args in list: <path-to-nodejs> and <path-to-this-CLI-script-file>
12
13
 
13
14
  while (args.length) {
14
15
  var arg = args[0];
@@ -0,0 +1,26 @@
1
+
2
+ const { spawn } = require('child_process');
3
+
4
+ function print(data) {
5
+ process.stdout.write(`${data}`);
6
+ }
7
+
8
+ function printErr(fullCommand, error) {
9
+ process.stdout.write(`[BINHEND][CLI] Error executing command: ${fullCommand}\n`);
10
+ process.stdout.write(`${error}`);
11
+ }
12
+
13
+ module.exports = function() {
14
+ const command = arguments[0], args = arguments[1],
15
+ fullCommand = `${command} ${args.join(' ')}`,
16
+
17
+ printError = printErr.bind(null, fullCommand),
18
+
19
+ child = spawn.apply(null, arguments);
20
+
21
+ child.stdout.on('data', print);
22
+
23
+ child.stderr.on('data', printError);
24
+
25
+ child.on('error', printError);
26
+ };
@@ -0,0 +1,11 @@
1
+
2
+ const path = require('path');
3
+ const fs = require('fs');
4
+
5
+ module.exports = function() {
6
+ const args = Array.from(arguments),
7
+ currentWorkingDirectory = process.cwd(), // directory path where the command is executed
8
+ destinationPath = path.join.apply(null, [currentWorkingDirectory].concat(args));
9
+
10
+ return destinationPath;
11
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "binhend",
3
- "version": "1.5.9",
3
+ "version": "1.5.11",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "Nguyen Duc Binh",
package/test/package.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "name": "palindrome",
3
- "version": "1.0.0",
4
- "description": "",
5
- "main": "index.js",
6
- "directories": {
7
- "test": "test"
8
- },
9
- "scripts": {
10
- "test": "istanbul cover node_modules/mocha/bin/_mocha"
11
- },
12
- "author": "",
13
- "license": "ISC",
14
- "devDependencies": {
15
- "chai": "^3.5.0",
16
- "istanbul": "^0.4.4",
17
- "mocha": "^3.0.1"
18
- }
19
- }