Clean up tests

This commit is contained in:
2020-03-25 11:47:51 -04:00
parent 5f83a8752a
commit 1e11110408
3 changed files with 12 additions and 28 deletions
+8 -5
View File
@@ -2,8 +2,11 @@
const bin = require('.'); const bin = require('.');
bin.run(['version']).then(() => { (async () => {
console.log('✔ Hugo installed successfully!'); try {
}).catch(error => { await bin.run(['version']);
console.error('✖ ERROR: Hugo installation failed. :(\n', error); console.log(' Hugo installed successfully!');
}); } catch (error) {
console.error('✖ ERROR: Hugo installation failed. :(\n', error);
}
})();
+2 -7
View File
@@ -35,7 +35,7 @@
}, },
"scripts": { "scripts": {
"postinstall": "node lib/install.js", "postinstall": "node lib/install.js",
"test": "xo && mocha" "test": "xo && mocha && node cli.js env"
}, },
"engines": { "engines": {
"node": ">=10" "node": ">=10"
@@ -49,14 +49,9 @@
"hugo": "cli.js" "hugo": "cli.js"
}, },
"xo": { "xo": {
"envs": [
"es6",
"node"
],
"space": true, "space": true,
"rules": { "rules": {
"object-curly-spacing": "off", "object-curly-spacing": "off"
"promise/prefer-await-to-then": "warn"
} }
} }
} }
+2 -16
View File
@@ -5,21 +5,7 @@
const assert = require('assert'); const assert = require('assert');
const binCheck = require('bin-check'); const binCheck = require('bin-check');
const hugoBin = require('..'); const hugoBin = require('..');
const { execFile } = require('child_process');
it('Hugo exists and runs?', () => { it('Hugo exists and runs?', async () => {
return binCheck(hugoBin, ['version']).then(works => { assert(await binCheck(hugoBin, ['version']));
assert(works);
// Print additional build environment variables if check successful
if (works) {
execFile(hugoBin, ['env'], (error, stdout) => {
if (error) {
throw error;
}
console.log(stdout);
});
}
});
}); });