binhend 1.5.14 → 1.5.16

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.
@@ -10,6 +10,8 @@ module.exports = (args) => {
10
10
 
11
11
  console.log('[BINHEND][CLI] Generate front-end structure:', destinationPath);
12
12
  fs.cpSync(sourcePath, destinationPath, {recursive: true});
13
+
14
+ // TODO logic adding excluded directories to .gitignore
13
15
  }
14
16
  catch (error) {
15
17
  console.error('[BINHEND][CLI] Error generating front-end structure!');
@@ -3,8 +3,18 @@ const runCommand = require('../utils/cmdRun');
3
3
  const cwdJoin = require('../utils/cwdJoin');
4
4
 
5
5
  module.exports = (args) => {
6
- // var projectFolder = args.shift() || './';
7
- // var scriptPath = cwdJoin(projectFolder, 'test/test.js');
8
- var testFolder = cwdJoin(projectFolder, 'test');
9
- runCommand(`cd ${testFolder} & node test.js`);
6
+ var projectFolder = args.shift() || './',
7
+
8
+ testFolder = cwdJoin(projectFolder, 'test'),
9
+
10
+ options = { cwd: testFolder },
11
+
12
+ npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
13
+
14
+ console.log(`[BINHEND][CLI] Setup testing environment: ${testFolder}`);
15
+ runCommand(npm, ['install'], options).done(() => {
16
+
17
+ console.log(`[BINHEND][CLI] Start testing: ${testFolder}`);
18
+ runCommand('node', ['test.js'].concat(args), options);
19
+ });
10
20
  };
@@ -2,7 +2,7 @@ const { Binh } = require('binhend');
2
2
 
3
3
  const app = new Binh();
4
4
 
5
- app.config('config.js', afterLoadedConfigs); // import module from path './config.js' to run and load configs
5
+ app.config('config/config.js', afterLoadedConfigs); // import module from path './config/config.js' to run and load configs
6
6
 
7
7
  function afterLoadedConfigs(configs) {
8
8
  const options = {
@@ -1,6 +1,6 @@
1
1
  const path = require('path');
2
2
 
3
3
  module.exports = function(loader) {
4
- loader.file(path.join(__dirname, '.env'));
4
+ loader.file(path.join(__dirname, 'default.env'));
5
5
  loader.cli();
6
6
  };
@@ -1,8 +1,8 @@
1
1
  module.exports = function(config) {
2
-
3
- const SCRIPT_INCLUDED_PATTERN = 'build/web/**/*.js';
2
+ const BUILD_PATH = 'build/web';
3
+ const SCRIPT_INCLUDED_PATTERN = `${BUILD_PATH}/**/*.js`;
4
4
  const TEST_INCLUDED_PATTERN = '../src/**/*.test.js';
5
- const TEST_EXCLUDED_PATTERN = 'build/web/**/*.test.js';
5
+ const TEST_EXCLUDED_PATTERN = `${BUILD_PATH}/**/*.test.js`;
6
6
 
7
7
  config.set({
8
8
  frameworks: ['mocha', 'chai'], // Use Mocha and Chai for testing
@@ -30,7 +30,7 @@ module.exports = function(config) {
30
30
  require('./binhend-preprocessor')
31
31
  ],
32
32
  binhend: {
33
- rootPath: require('path').resolve(__dirname, 'web').replace(/\\/g, '/')
33
+ rootPath: require('path').resolve(__dirname, BUILD_PATH).replace(/\\/g, '/')
34
34
  },
35
35
 
36
36
  mochaReporter: { // Configure Mocha reporter options
@@ -4,7 +4,7 @@
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "UNLICENSED",
7
- "main": "index.js",
7
+ "main": "test.js",
8
8
  "devDependencies": {
9
9
  "chai": "^4.3.7",
10
10
  "karma": "^6.4.3",
@@ -20,6 +20,6 @@
20
20
  "npm": ">=8.15.0"
21
21
  },
22
22
  "scripts": {
23
- "test": "npm i & node index.js"
23
+ "test": "npm i & node test.js"
24
24
  }
25
25
  }
@@ -1,26 +1,32 @@
1
1
 
2
2
  const { spawn } = require('child_process');
3
3
 
4
- function print(data) {
4
+ function printOut(data) {
5
5
  process.stdout.write(`${data}`);
6
6
  }
7
7
 
8
- function printErr(fullCommand, error) {
9
- process.stdout.write(`[BINHEND][CLI] Error executing command: ${fullCommand}\n`);
10
- process.stdout.write(`${error}`);
8
+ function printError(error) {
9
+ process.stderr.write(`${error}`);
11
10
  }
12
11
 
13
12
  module.exports = function() {
14
- const command = arguments[0], args = arguments[1] || [],
15
- fullCommand = `${command} ${args.join(' ')}`,
16
-
17
- printError = printErr.bind(null, fullCommand),
13
+ var ref = {}, onClosed = () => {},
18
14
 
19
15
  child = spawn.apply(null, arguments);
20
16
 
21
- child.stdout.on('data', print);
17
+ child.stdout.on('data', printOut);
22
18
 
23
19
  child.stderr.on('data', printError);
24
20
 
25
21
  child.on('error', printError);
26
- };
22
+
23
+ child.on('close', (code) => {
24
+ onClosed(code);
25
+ });
26
+
27
+ ref.done = (callback) => {
28
+ onClosed = callback instanceof Function ? callback : () => {};
29
+ };
30
+
31
+ return ref;
32
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "binhend",
3
- "version": "1.5.14",
3
+ "version": "1.5.16",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "Nguyen Duc Binh",