diff --git a/.gitignore b/.gitignore index 79e0cb9..811009d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ *.pid *.gz *.orig +*.swp dist work @@ -19,6 +20,7 @@ html-report xunit.xml node_modules npm-debug.log +.nyc_output .project .idea diff --git a/lib/factory.js b/lib/factory.js index c8b7ee5..ca369e5 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -14,7 +14,7 @@ │ limitations under the License. │ \*───────────────────────────────────────────────────────────────────────────*/ import Path from 'path'; -import shush from 'shush'; +import loadJsonicSync from 'load-jsonic-sync'; import debuglog from 'debuglog'; import Thing from 'core-util-is'; import Config from './config'; @@ -34,13 +34,13 @@ export default class Factory { .then(store => Common.merge(Provider.convenience(), store)) .then(Factory.conditional(store => { let file = Path.join(this.basedir, defaults); - return Handlers.resolveImport(shush(file), this.basedir) + return Handlers.resolveImport(loadJsonicSync(file), this.basedir) .then(data => Common.merge(data, store)); })) .then(Factory.conditional(store => { let file = Path.join(this.basedir, `${store.env.env}.json`); - return Handlers.resolveImport(shush(file), this.basedir) - .then(data => Common.merge(shush(file), store)); + return Handlers.resolveImport(loadJsonicSync(file), this.basedir) + .then(data => Common.merge(loadJsonicSync(file), store)); })) .then(store => Common.merge(Provider.env(), store)) .then(store => Common.merge(Provider.argv(), store)); @@ -73,7 +73,7 @@ export default class Factory { _resolveFile(path) { if (Thing.isString(path)) { let file = Common.isAbsolute(path) ? path : Path.join(this.basedir, path); - return shush(file); + return loadJsonicSync(file); } return path; } @@ -83,7 +83,7 @@ export default class Factory { try { return fn(store); } catch (err) { - if (err.code && err.code === 'MODULE_NOT_FOUND') { + if (err.cause() && err.cause().code === 'ENOENT') { debug(`WARNING: ${err.message}`); return store; } diff --git a/lib/handlers.js b/lib/handlers.js index 2e8993b..4de6aa3 100644 --- a/lib/handlers.js +++ b/lib/handlers.js @@ -13,7 +13,7 @@ │ See the License for the specific language governing permissions and │ │ limitations under the License. │ \*───────────────────────────────────────────────────────────────────────────*/ -import shush from 'shush'; +import loadJsonicSync from 'load-jsonic-sync'; import async from 'async'; import Shortstop from 'shortstop' import { path as createPath } from 'shortstop-handlers'; @@ -79,7 +79,7 @@ export default class Handlers { shorty.use('import', function (file, cb) { try { file = path(file); - return shorty.resolve(shush(file), cb); + return shorty.resolve(loadJsonicSync(file), cb); } catch (err) { cb(err); } diff --git a/package.json b/package.json index a5ee761..c4e6b47 100644 --- a/package.json +++ b/package.json @@ -4,14 +4,14 @@ "description": "Environment-aware configuration.", "main": "dist/index.js", "directories": { - "test": "test", - "dist": "dist" + "dist": "dist", + "test": "test" }, "scripts": { "compile": "babel --optional runtime --modules common --out-dir dist index.js lib/**.js", + "cover": "npm run compile && nyc tap test/**/*-test.js && nyc report -r html", "prepublish": "npm run compile", - "test": "npm run compile && babel-node test/harness.js test/**/*-test.js", - "cover": "npm run compile && babel-node node_modules/.bin/istanbul cover test/harness.js test/**/*-test.js" + "test": "npm run compile && tap test/**/*-test.js" }, "repository": { "type": "git", @@ -19,8 +19,8 @@ }, "keywords": [ "application", - "configuration", - "config" + "config", + "configuration" ], "author": "Erik Toth ", "licenses": [ @@ -35,7 +35,8 @@ "glob": "^4.3.5", "istanbul": "^0.3.5", "jshint": "^2.6.0", - "tape": "^3.5.0" + "nyc": "^3.0.1", + "tap": "^1.3.1" }, "dependencies": { "async": "^0.9.0", @@ -43,9 +44,9 @@ "caller": "^1.0.0", "core-util-is": "^1.0.1", "debuglog": "^1.0.1", + "load-jsonic-sync": "^1.0.0", "minimist": "^1.1.0", "shortstop": "^1.0.1", - "shortstop-handlers": "^1.0.0", - "shush": "^1.0.0" + "shortstop-handlers": "^1.0.0" } } diff --git a/test/common-test.js b/test/common-test.js index 6763ac5..506a968 100644 --- a/test/common-test.js +++ b/test/common-test.js @@ -1,6 +1,7 @@ 'use strict'; -var test = require('tape'); +require('babel/register'); +var test = require('tap').test; var common = require('../lib/common'); @@ -76,4 +77,4 @@ test('merge with existing props', function (t) { }); t.end(); -}); \ No newline at end of file +}); diff --git a/test/confit-test.js b/test/confit-test.js index ba42728..afd52a5 100644 --- a/test/confit-test.js +++ b/test/confit-test.js @@ -1,7 +1,7 @@ 'use strict'; var path = require('path'); -var test = require('tape'); +var test = require('tap').test; var confit = require('../'); var env = process.env.NODE_ENV; @@ -201,7 +201,7 @@ test('confit', function (t) { .create(function (err, config) { t.ok(err); t.notOk(config); - t.equal(err.code, 'MODULE_NOT_FOUND'); + t.equal(err.cause().code, 'ENOENT'); t.end(); }); }); @@ -446,7 +446,13 @@ test('confit', function (t) { var basedir = path.join(__dirname, 'fixtures', 'malformed'); confit(basedir).create(function (err, config) { t.ok(err); - t.notOk(config) + t.matches(err.message, /loading jsonic file.*fixtures/); + t.matches(err.cause().message, /pair rule failed at: \d/); + t.matches(err.cause(), { + line: 1, + column: 3 + }); + t.notOk(config); t.end(); }); }); diff --git a/test/harness.js b/test/harness.js index 9e0f87e..59d0352 100644 --- a/test/harness.js +++ b/test/harness.js @@ -1,4 +1,4 @@ -var tape = require('tape'); +var tape = require('tap').test; var glob = require('glob'); var Path = require('path'); diff --git a/test/provider-test.js b/test/provider-test.js index 2b205a1..919bc0b 100644 --- a/test/provider-test.js +++ b/test/provider-test.js @@ -1,9 +1,9 @@ 'use strict'; -var test = require('tape'); +require('babel/register'); +var test = require('tap').test; var provider = require('../lib/provider'); - test('env', function (t) { var env = process.env; @@ -49,6 +49,8 @@ test('argv', function (t) { t.equal(val.h, null); t.end(); }); + + t.end(); }); @@ -148,4 +150,6 @@ test('convenience', function (t) { t.notOk(val.env.production); t.end(); }); + + t.end(); });