editions
Advanced tools
Comparing version 1.1.1 to 1.1.2
'use strict'; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
/* @flow */ | ||
@@ -7,3 +13,24 @@ /* eslint no-console:0 */ | ||
// Helper class to display nested error in a sensible way | ||
var NestedError = function (_Error) { | ||
_inherits(NestedError, _Error); | ||
function NestedError(message /* :string */, parent /* :Error */) { | ||
_classCallCheck(this, NestedError); | ||
message += ' due to next parent error'; | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(NestedError).call(this, message)); | ||
_this.stack += '\n\nParent ' + (parent.stack || parent.message || parent).toString(); | ||
return _this; | ||
} | ||
return NestedError; | ||
}(Error); | ||
// Cache of which syntax combinations are supported or unsupported, hash of booleans | ||
var syntaxFailures = {}; | ||
@@ -35,3 +62,3 @@ | ||
if (!editions || editions.length === 0) { | ||
throw new Error('No editions have been specified for the package ' + name); | ||
throw new Error('No editions have been specified for the package [' + name + ']'); | ||
} | ||
@@ -52,8 +79,8 @@ | ||
// Checks | ||
// Checks with hard failures to alert the developer | ||
if (customEntry && !directory) { | ||
throw new Error('The package ' + name + ' has no directory property on its editions which is required when using custom entry point: ' + customEntry); | ||
throw new Error('The package [' + name + '] has no directory property on its editions which is required when using custom entry point: ' + customEntry); | ||
} else if (!entry) { | ||
throw new Error('The package ' + name + ' has no entry property on its editions which is required when using default entry'); | ||
throw new Error('The package [' + name + '] has no entry property on its editions which is required when using default entry'); | ||
} | ||
@@ -69,5 +96,6 @@ | ||
// Is this syntax combination unsupported? If so skip it | ||
// Is this syntax combination unsupported? If so skip it with a soft failure to try the next edition | ||
if (s && syntaxFailures[s]) { | ||
lastEditionFailure = new Error('Skipped package ' + name + ' edition at ' + entryPath + ' due to blacklisted syntax:\n' + s + '\n' + syntaxFailures[s].stack); | ||
var syntaxFailure = syntaxFailures[s]; | ||
lastEditionFailure = new NestedError('Skipped package [' + name + '] edition at [' + entryPath + '] with blacklisted syntax [' + s + ']', syntaxFailure); | ||
if (debug) console.error('DEBUG: ' + lastEditionFailure.stack); | ||
@@ -82,3 +110,3 @@ continue; | ||
// Note the error with more details | ||
lastEditionFailure = new Error('Unable to load package ' + name + ' edition at ' + entryPath + ' with syntax:\n' + (s || 'no syntaxes specified') + '\n' + error.stack); | ||
lastEditionFailure = new NestedError('Unable to load package [' + name + '] edition at [' + entryPath + '] with syntax [' + (s || 'no syntaxes specified') + ']', error); | ||
if (debug) console.error('DEBUG: ' + lastEditionFailure.stack); | ||
@@ -93,3 +121,4 @@ | ||
// No edition was returned, so there is no suitable edition | ||
throw new Error('The package ' + name + ' has no suitable edition for this environment' + (lastEditionFailure && ', the last edition failed with:\n' + lastEditionFailure.stack || '')); | ||
if (!lastEditionFailure) lastEditionFailure = new Error('The package [' + name + '] failed without any actual errors...'); | ||
throw new NestedError('The package [' + name + '] has no suitable edition for this environment', lastEditionFailure); | ||
}; |
# History | ||
## v1.1.2 2016 June 16 | ||
- Parent errors are now displayed in a more sensible way | ||
## v1.1.1 2016 March 20 | ||
@@ -4,0 +7,0 @@ - Errors and debug messages are now more useful |
{ | ||
"name": "editions", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Publish multiple editions for your JavaScript packages consistently and easily (e.g. source edition, esnext edition, es2015 edition)", | ||
@@ -46,6 +46,6 @@ "homepage": "https://github.com/bevry/editions", | ||
"maintainers": [ | ||
"Benjamin Lupton <b@lupton.cc> (https://balupton.com)" | ||
"Benjamin Lupton <b@lupton.cc> (http://balupton.com)" | ||
], | ||
"contributors": [ | ||
"Benjamin Lupton <b@lupton.cc> (https://balupton.com)" | ||
"Benjamin Lupton <b@lupton.cc> (http://balupton.com)" | ||
], | ||
@@ -60,3 +60,3 @@ "bugs": { | ||
"engines": { | ||
"node": ">=0.12" | ||
"node": ">=0.10" | ||
}, | ||
@@ -109,13 +109,13 @@ "editions": [ | ||
"devDependencies": { | ||
"assert-helpers": "^4.1.0", | ||
"babel-cli": "^6.6.5", | ||
"babel-preset-es2015": "^6.6.0", | ||
"documentation": "^4.0.0-beta1", | ||
"eslint": "^2.4.0", | ||
"eslint-plugin-babel": "^3.1.0", | ||
"flow-bin": "^0.22.1", | ||
"joe": "^1.6.0", | ||
"assert-helpers": "^4.4.0", | ||
"babel-cli": "^6.10.1", | ||
"babel-polyfill": "^6.9.1", | ||
"babel-preset-es2015": "^6.9.0", | ||
"documentation": "^4.0.0-beta5", | ||
"eslint": "^2.12.0", | ||
"flow-bin": "^0.27.0", | ||
"joe": "^1.8.0", | ||
"joe-reporter-console": "^1.2.1", | ||
"projectz": "^1.1.2" | ||
"projectz": "^1.1.6" | ||
} | ||
} |
@@ -67,3 +67,3 @@ <!-- TITLE/ --> | ||
<ul><li><a href="https://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/editions/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/editions">view contributions</a></li></ul> | ||
<ul><li><a href="http://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/editions/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/editions">view contributions</a></li></ul> | ||
@@ -85,3 +85,3 @@ <h3>Sponsors</h3> | ||
<ul><li><a href="https://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/editions/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/editions">view contributions</a></li></ul> | ||
<ul><li><a href="http://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/editions/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/editions">view contributions</a></li></ul> | ||
@@ -88,0 +88,0 @@ <a href="https://github.com/bevry/editions/blob/master/CONTRIBUTING.md#files">Discover how you can contribute by heading on over to the <code>CONTRIBUTING.md</code> file.</a> |
@@ -5,2 +5,11 @@ /* @flow */ | ||
// Helper class to display nested error in a sensible way | ||
class NestedError extends Error { | ||
constructor (message /* :string */, parent /* :Error */) { | ||
message += ' due to next parent error' | ||
super(message) | ||
this.stack += '\n\nParent ' + (parent.stack || parent.message || parent).toString() | ||
} | ||
} | ||
// Cache of which syntax combinations are supported or unsupported, hash of booleans | ||
@@ -29,3 +38,3 @@ const syntaxFailures = {} | ||
if ( !editions || editions.length === 0 ) { | ||
throw new Error(`No editions have been specified for the package ${name}`) | ||
throw new Error(`No editions have been specified for the package [${name}]`) | ||
} | ||
@@ -43,8 +52,8 @@ | ||
// Checks | ||
// Checks with hard failures to alert the developer | ||
if ( customEntry && !directory ) { | ||
throw new Error(`The package ${name} has no directory property on its editions which is required when using custom entry point: ${customEntry}`) | ||
throw new Error(`The package [${name}] has no directory property on its editions which is required when using custom entry point: ${customEntry}`) | ||
} | ||
else if ( !entry ) { | ||
throw new Error(`The package ${name} has no entry property on its editions which is required when using default entry`) | ||
throw new Error(`The package [${name}] has no entry property on its editions which is required when using default entry`) | ||
} | ||
@@ -58,5 +67,6 @@ | ||
// Is this syntax combination unsupported? If so skip it | ||
// Is this syntax combination unsupported? If so skip it with a soft failure to try the next edition | ||
if ( s && syntaxFailures[s] ) { | ||
lastEditionFailure = new Error(`Skipped package ${name} edition at ${entryPath} due to blacklisted syntax:\n${s}\n${syntaxFailures[s].stack}`) | ||
const syntaxFailure = syntaxFailures[s] | ||
lastEditionFailure = new NestedError(`Skipped package [${name}] edition at [${entryPath}] with blacklisted syntax [${s}]`, syntaxFailure) | ||
if ( debug ) console.error(`DEBUG: ${lastEditionFailure.stack}`) | ||
@@ -72,3 +82,3 @@ continue | ||
// Note the error with more details | ||
lastEditionFailure = new Error(`Unable to load package ${name} edition at ${entryPath} with syntax:\n${s || 'no syntaxes specified'}\n${error.stack}`) | ||
lastEditionFailure = new NestedError(`Unable to load package [${name}] edition at [${entryPath}] with syntax [${s || 'no syntaxes specified'}]`, error) | ||
if ( debug ) console.error(`DEBUG: ${lastEditionFailure.stack}`) | ||
@@ -83,3 +93,4 @@ | ||
// No edition was returned, so there is no suitable edition | ||
throw new Error(`The package ${name} has no suitable edition for this environment${lastEditionFailure && ', the last edition failed with:\n' + lastEditionFailure.stack || ''}`) | ||
if ( !lastEditionFailure ) lastEditionFailure = new Error(`The package [${name}] failed without any actual errors...`) | ||
throw new NestedError(`The package [${name}] has no suitable edition for this environment`, lastEditionFailure) | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found
Found 1 instance in 1 package
1
100
21680
8
165
1