This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better error messages for missing binaries
This is another iteration on improving the infamous >The `libsass` binding was not found Messages will now provide more useful information which will - give users a chance to resolve the problem themselves - give us more debug information from the error message alone Error messages produce now will look like: >Node Sass does not yet support your current environment: OS X 64-bit with Node.js 4.x >For more information on which environments are supported please see: >http://.... >Node Sass could not find a binding for your current environment: OS X 64-bit with Node.js 4.x >Found bindings for the following environments: > - OS X 64-bit with io.js 3.x > - OS X 64-bit with Node.js 5.x >This usually happens because your environment has changed since running `npm install`. >Run `npm rebuild node-sass` to build the binding for your current environment. >Node Sass could not find a binding for your current environment: OS X 64-bit with Node.js 4.x >This usually happens because your environment has changed since running `npm install`. >Run `npm rebuild node-sass` to build the binding for your current environment.
- Loading branch information
Showing
6 changed files
with
294 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/*! | ||
* node-sass: lib/errors.js | ||
*/ | ||
|
||
var sass = require('./extensions'); | ||
|
||
function humanEnvironment() { | ||
return sass.getHumanEnvironment(sass.getBinaryName()); | ||
} | ||
|
||
function foundBinaries() { | ||
return [ | ||
'Found bindings for the following environments:', | ||
foundBinariesList(), | ||
].join('\n'); | ||
} | ||
|
||
function foundBinariesList() { | ||
return sass.getInstalledBinaries().map(function(env) { | ||
return ' - ' + sass.getHumanEnvironment(env); | ||
}).join('\n'); | ||
} | ||
|
||
function missingBinaryFooter() { | ||
return [ | ||
'This usually happens because your environment has changed since running `npm install`.', | ||
'Run `npm rebuild node-sass` to build the binding for your current environment.', | ||
].join('\n'); | ||
} | ||
|
||
module.exports.unsupportedEnvironment = function() { | ||
return [ | ||
'Node Sass does not yet support your current environment: ' + humanEnvironment(), | ||
'For more information on which environments are supported please see:', | ||
'TODO URL' | ||
].join('\n'); | ||
}; | ||
|
||
module.exports.missingBinary = function() { | ||
return [ | ||
'Missing binding ' + sass.getBinaryPath(), | ||
'Node Sass could not find a binding for your current environment: ' + humanEnvironment(), | ||
'', | ||
foundBinaries(), | ||
'', | ||
missingBinaryFooter(), | ||
].join('\n'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
var assert = require('assert'), | ||
errors = require('../lib/errors'); | ||
|
||
describe('binary errors', function() { | ||
|
||
function getCurrentPlatform() { | ||
if (process.platform === 'win32') { | ||
return 'Windows'; | ||
} else if (process.platform === 'darwin') { | ||
return 'OS X'; | ||
} | ||
return ''; | ||
} | ||
|
||
function getCurrentArchitecture() { | ||
if (process.arch === 'x86' || process.arch === 'ia32') { | ||
return '32-bit'; | ||
} else if (process.arch === 'x64') { | ||
return '64-bit'; | ||
} | ||
return ''; | ||
} | ||
|
||
function getCurrentEnvironment() { | ||
return getCurrentPlatform() + ' ' + getCurrentArchitecture(); | ||
} | ||
|
||
describe('for an unsupported environment', function() { | ||
it('identifies the current environment', function() { | ||
var message = errors.unsupportedEnvironment(); | ||
assert.ok(message.indexOf(getCurrentEnvironment()) !== -1); | ||
}); | ||
|
||
it('links to supported environment documentation', function() { | ||
var message = errors.unsupportedEnvironment(); | ||
assert.ok(message.indexOf('TODO URL') !== -1); | ||
}); | ||
}); | ||
|
||
describe('for an missing binary', function() { | ||
it('identifies the current environment', function() { | ||
var message = errors.missingBinary(); | ||
assert.ok(message.indexOf(getCurrentEnvironment()) !== -1); | ||
}); | ||
|
||
it('documents the expected binary location', function() { | ||
var message = errors.missingBinary(); | ||
assert.ok(message.indexOf('/vendor/') !== -1); | ||
}); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters