feat: ✨ Created a mini nodeJS server with NewMan for testing without PostMan GUI.
This will mimic a run in a CD/CI environment or docker container.
This commit is contained in:
41
node_modules/liquid-json/npm/test-lint.js
generated
vendored
Normal file
41
node_modules/liquid-json/npm/test-lint.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env node
|
||||
require('shelljs/global');
|
||||
require('colors');
|
||||
|
||||
var async = require('async'),
|
||||
ESLintCLIEngine = require('eslint').CLIEngine,
|
||||
|
||||
LINT_SOURCE_DIRS = [
|
||||
'./lib',
|
||||
'./bin',
|
||||
'./test',
|
||||
'./examples/*.js',
|
||||
'./npm/*.js',
|
||||
'./index.js'
|
||||
];
|
||||
|
||||
module.exports = function (exit) {
|
||||
// banner line
|
||||
console.info('\nLinting files using eslint...'.yellow.bold);
|
||||
|
||||
async.waterfall([
|
||||
// execute the CLI engine
|
||||
function (next) {
|
||||
next(null, (new ESLintCLIEngine()).executeOnFiles(LINT_SOURCE_DIRS));
|
||||
},
|
||||
|
||||
// output results
|
||||
function (report, next) {
|
||||
var errorReport = ESLintCLIEngine.getErrorResults(report.results);
|
||||
// log the result to CLI
|
||||
console.info(ESLintCLIEngine.getFormatter()(report.results));
|
||||
// log the success of the parser if it has no errors
|
||||
(errorReport && !errorReport.length) && console.info('eslint ok!'.green);
|
||||
// ensure that the exit code is non zero in case there was an error
|
||||
next(Number(errorReport && errorReport.length) || 0);
|
||||
}
|
||||
], exit);
|
||||
};
|
||||
|
||||
// ensure we run this script exports if this is a direct stdin.tty run
|
||||
!module.parent && module.exports(exit);
|
31
node_modules/liquid-json/npm/test-unit.js
generated
vendored
Normal file
31
node_modules/liquid-json/npm/test-unit.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env node
|
||||
require('shelljs/global');
|
||||
require('colors');
|
||||
|
||||
var fs = require('fs'),
|
||||
path = require('path'),
|
||||
Mocha = require('mocha'),
|
||||
|
||||
SPEC_SOURCE_DIR = './test/unit';
|
||||
|
||||
module.exports = function (exit) {
|
||||
// banner line
|
||||
console.info('Running unit tests using mocha...'.yellow.bold);
|
||||
|
||||
var mocha = new Mocha();
|
||||
|
||||
fs.readdir(SPEC_SOURCE_DIR, function (err, files) {
|
||||
files.filter(function (file) {
|
||||
return (file.substr(-8) === '.test.js');
|
||||
}).forEach(function (file) {
|
||||
mocha.addFile(path.join(SPEC_SOURCE_DIR, file));
|
||||
});
|
||||
|
||||
// start the mocha run
|
||||
mocha.run(exit);
|
||||
mocha = null; // cleanup
|
||||
});
|
||||
};
|
||||
|
||||
// ensure we run this script exports if this is a direct stdin.tty run
|
||||
!module.parent && module.exports(exit);
|
16
node_modules/liquid-json/npm/test.js
generated
vendored
Normal file
16
node_modules/liquid-json/npm/test.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env node
|
||||
require('shelljs/global');
|
||||
require('colors');
|
||||
|
||||
var prettyms = require('pretty-ms'),
|
||||
startedAt = Date.now();
|
||||
|
||||
require('async').series([
|
||||
require('./test-lint'),
|
||||
require('./test-unit')
|
||||
], function (code) {
|
||||
// eslint-disable-next-line max-len
|
||||
console.info(`\nliquid-json: duration ${prettyms(Date.now() - startedAt)}\nliquid-json: ${code ? 'not ok' : 'ok'}!`[code ?
|
||||
'red' : 'green']);
|
||||
exit(code && (typeof code === 'number' ? code : 1) || 0);
|
||||
});
|
Reference in New Issue
Block a user