Comparing version 1.1.0 to 1.1.1
@@ -8,3 +8,3 @@ 'use strict'; | ||
// Cache of which syntax combinations are supported or unsupported, hash of booleans | ||
var supportedSyntaxes = {}; | ||
var syntaxFailures = {}; | ||
@@ -22,2 +22,3 @@ /** | ||
var debug = process && process.env && process.env.DEBUG_BEVRY_EDITIONS; | ||
// const blacklist = process && process.env && process.env.DEBUG_BEVRY_IGNORE_BLACKLIST | ||
@@ -34,4 +35,10 @@ // Load the package.json file to fetch `name` for debugging and `editions` for loading | ||
if (!editions || editions.length === 0) { | ||
throw new Error('No editions have been specified for the package ' + name); | ||
} | ||
// Note the last error message | ||
var lastEditionFailure = void 0; | ||
// Cycle through the editions | ||
for (var i = 0; i < editions.length; ++i) { | ||
@@ -49,5 +56,5 @@ // Extract relevant parts out of the edition | ||
if (customEntry && !directory) { | ||
throw new Error('The package ' + name + ' did not specify a directory property on its editions which is required for the 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 + ' did not specify a entry property on its editions which is required for default entry'); | ||
throw new Error('The package ' + name + ' has no entry property on its editions which is required when using default entry'); | ||
} | ||
@@ -64,3 +71,5 @@ | ||
// Is this syntax combination unsupported? If so skip it | ||
if (s && supportedSyntaxes[s] === false) { | ||
if (s && syntaxFailures[s]) { | ||
lastEditionFailure = new Error('Skipped package ' + name + ' edition at ' + entryPath + ' due to blacklisted syntax:\n' + s + '\n' + syntaxFailures[s].stack); | ||
if (debug) console.error('DEBUG: ' + lastEditionFailure.stack); | ||
continue; | ||
@@ -73,12 +82,9 @@ } | ||
} catch (error) { | ||
// The combination failed so debug it | ||
if (debug) { | ||
console.error('DEBUG: ' + new Error('The package ' + name + ' failed to load the edition at ' + entryPath + ' with syntaxes:\n' + (s || 'no syntaxes specified') + '\n\n' + error.stack).stack); | ||
} | ||
// 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); | ||
if (debug) console.error('DEBUG: ' + lastEditionFailure.stack); | ||
// Blacklist the combination, even if it may have worked before | ||
// Perhaps in the future note if that if it did work previously, then we should instruct module owners to be more specific with their syntaxes | ||
if (s) { | ||
supportedSyntaxes[s] = false; | ||
} | ||
if (s) syntaxFailures[s] = lastEditionFailure; | ||
} | ||
@@ -88,3 +94,3 @@ } | ||
// No edition was returned, so there is no suitable edition | ||
throw new Error('The package ' + name + ' has no suitable edition for this environment'); | ||
throw new Error('The package ' + name + ' has no suitable edition for this environment' + (lastEditionFailure && ', the last edition failed with:\n' + lastEditionFailure.stack || '')); | ||
}; |
# History | ||
## v1.1.1 2016 March 20 | ||
- Errors and debug messages are now more useful | ||
- Closes https://github.com/bevry/editions/issues/5 | ||
## v1.1.0 2016 March 20 | ||
@@ -4,0 +8,0 @@ - Added support for custom entry point overrides |
{ | ||
"name": "editions", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Publish multiple editions for your JavaScript packages consistently and easily (e.g. source edition, esnext edition, es2015 edition)", | ||
@@ -96,3 +96,4 @@ "homepage": "https://github.com/bevry/editions", | ||
"prepare": "npm run compile && npm run test && npm run meta", | ||
"release": "npm run prepare && npm run release:tag && npm run release:push", | ||
"release": "npm run prepare && npm run release:publish && npm run release:tag && npm run release:push", | ||
"release:publish": "npm publish", | ||
"release:tag": "git tag v$npm_package_version -a", | ||
@@ -110,4 +111,4 @@ "release:push": "git push origin master && git push origin --tags", | ||
"babel-preset-es2015": "^6.6.0", | ||
"documentation": "^4.0.0-beta", | ||
"eslint": "^2.3.0", | ||
"documentation": "^4.0.0-beta1", | ||
"eslint": "^2.4.0", | ||
"eslint-plugin-babel": "^3.1.0", | ||
@@ -117,4 +118,4 @@ "flow-bin": "^0.22.1", | ||
"joe-reporter-console": "^1.2.1", | ||
"projectz": "^1.0.9" | ||
"projectz": "^1.1.2" | ||
} | ||
} |
@@ -38,3 +38,5 @@ <!-- TITLE/ --> | ||
[View the API documentation.](http://rawgit.com/bevry/editions/master/docs/index.html) | ||
<!-- HISTORY/ --> | ||
@@ -41,0 +43,0 @@ |
@@ -6,3 +6,3 @@ /* @flow */ | ||
// Cache of which syntax combinations are supported or unsupported, hash of booleans | ||
const supportedSyntaxes = {} | ||
const syntaxFailures = {} | ||
@@ -20,2 +20,3 @@ /** | ||
const debug = process && process.env && process.env.DEBUG_BEVRY_EDITIONS | ||
// const blacklist = process && process.env && process.env.DEBUG_BEVRY_IGNORE_BLACKLIST | ||
@@ -28,2 +29,9 @@ // Load the package.json file to fetch `name` for debugging and `editions` for loading | ||
if ( !editions || editions.length === 0 ) { | ||
throw new Error(`No editions have been specified for the package ${name}`) | ||
} | ||
// Note the last error message | ||
let lastEditionFailure | ||
// Cycle through the editions | ||
@@ -38,6 +46,6 @@ for ( let i = 0; i < editions.length; ++i ) { | ||
if ( customEntry && !directory ) { | ||
throw new Error(`The package ${name} did not specify a directory property on its editions which is required for the 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} did not specify a entry property on its editions which is required for default entry`) | ||
throw new Error(`The package ${name} has no entry property on its editions which is required when using default entry`) | ||
} | ||
@@ -52,3 +60,5 @@ | ||
// Is this syntax combination unsupported? If so skip it | ||
if ( s && supportedSyntaxes[s] === false ) { | ||
if ( s && syntaxFailures[s] ) { | ||
lastEditionFailure = new Error(`Skipped package ${name} edition at ${entryPath} due to blacklisted syntax:\n${s}\n${syntaxFailures[s].stack}`) | ||
if ( debug ) console.error(`DEBUG: ${lastEditionFailure.stack}`) | ||
continue | ||
@@ -62,12 +72,9 @@ } | ||
catch ( error ) { | ||
// The combination failed so debug it | ||
if ( debug ) { | ||
console.error('DEBUG: ' + new Error(`The package ${name} failed to load the edition at ${entryPath} with syntaxes:\n${s || 'no syntaxes specified'}\n\n${error.stack}`).stack) | ||
} | ||
// 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}`) | ||
if ( debug ) console.error(`DEBUG: ${lastEditionFailure.stack}`) | ||
// Blacklist the combination, even if it may have worked before | ||
// Perhaps in the future note if that if it did work previously, then we should instruct module owners to be more specific with their syntaxes | ||
if ( s ) { | ||
supportedSyntaxes[s] = false | ||
} | ||
if ( s ) syntaxFailures[s] = lastEditionFailure | ||
} | ||
@@ -77,3 +84,3 @@ } | ||
// No edition was returned, so there is no suitable edition | ||
throw new Error(`The package ${name} has no suitable edition for this environment`) | ||
throw new Error(`The package ${name} has no suitable edition for this environment${lastEditionFailure && ', the last edition failed with:\n' + lastEditionFailure.stack || ''}`) | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
641929
1243
104
0