Commit 4c14f27e by Adeel Mujahid

Merge pull request #668 from am11/master

Misc. Fixes
parents dfc026ba 60201f7d
...@@ -75,7 +75,7 @@ The API for using node-sass has changed, so that now there is only one variable ...@@ -75,7 +75,7 @@ The API for using node-sass has changed, so that now there is only one variable
`data` is a `String` containing the scss to be rendered by [libsass]. One of this or `file` options are required, for both render and renderSync. It is recommended that you use the `includePaths` option in conjunction with this, as otherwise [libsass] may have trouble finding files imported via the `@import` directive. `data` is a `String` containing the scss to be rendered by [libsass]. One of this or `file` options are required, for both render and renderSync. It is recommended that you use the `includePaths` option in conjunction with this, as otherwise [libsass] may have trouble finding files imported via the `@import` directive.
#### success #### success
`success` is a `Function` to be called upon successful rendering of the scss to css. This option is required but only for the render function. If provided to renderSync it will be ignored. `success` is a `Function` to be called upon successful rendering of the scss to css. This option is required but only for the render function. If provided to `renderSync` it will be ignored. The error object take
The callback function is passed a results object, containing the following keys: The callback function is passed a results object, containing the following keys:
...@@ -89,7 +89,17 @@ The callback function is passed a results object, containing the following keys: ...@@ -89,7 +89,17 @@ The callback function is passed a results object, containing the following keys:
* `includedFiles` - Absolute paths to all related scss files in no particular order. * `includedFiles` - Absolute paths to all related scss files in no particular order.
#### error #### error
`error` is a `Function` to be called upon occurrence of an error when rendering the scss to css. This option is optional, and only applies to the render function. If provided to renderSync it will be ignored. `error` is a `Function` to be called upon occurrence of an error when rendering the scss to css. This option is optional, and only applies to the render function.
The callback function is passed an error object, containing the following keys:
* `message` - The error message.
* `line` - The line number of error.
* `column` - The column number of error.
* `status` - The status code.
* `file` - The filename of error. In case `file` option was not set (in favour of `data`), this will reflect the value `stdin`.
Note: If this option is provided to renderSync it will be ignored. In case of `renderSync` the error is thrown to stderr, which is try-catchable. In catch block, the same error object will be received.
#### importer (starting from v2) #### importer (starting from v2)
`importer` is a `Function` to be called when libsass parser encounters the import directive. If present, libsass will call node-sass and let the user change file, data or both during the compilation. This option is optional, and applies to both render and renderSync functions. Also, it can either return object of form `{file:'..', contents: '..'}` or send it back via `done({})`. Note in renderSync or render, there is no restriction imposed on using `done()` callback or `return` statement (dispite of the asnchrony difference). `importer` is a `Function` to be called when libsass parser encounters the import directive. If present, libsass will call node-sass and let the user change file, data or both during the compilation. This option is optional, and applies to both render and renderSync functions. Also, it can either return object of form `{file:'..', contents: '..'}` or send it back via `done({})`. Note in renderSync or render, there is no restriction imposed on using `done()` callback or `return` statement (dispite of the asnchrony difference).
...@@ -141,10 +151,10 @@ sass.render({ ...@@ -141,10 +151,10 @@ sass.render({
console.log(result.stats); console.log(result.stats);
console.log(result.map) console.log(result.map)
}, },
error: function(error) { error: function(error) { // starting v2.1 error is an Error-typed object
// error is an object: v2 change // error is an object: v2 change
console.log(error.message); console.log(error.message);
console.log(error.code); console.log(error.status); // changed from code to status in v2.1
console.log(error.line); console.log(error.line);
console.log(error.column); // new in v2 console.log(error.column); // new in v2
}, },
...@@ -279,9 +289,6 @@ npm install -g node-gyp ...@@ -279,9 +289,6 @@ npm install -g node-gyp
node-gyp rebuild # to make debug release, use -d switch node-gyp rebuild # to make debug release, use -d switch
``` ```
### Workaround for node `v0.11.13` `v0.11.14`
Follow the steps above, but comment out this [line](https://github.com/sass/node-sass/blob/e01497c4d4b8a7a7f4dbf9d607920ac10ad64445/lib/index.js#L181) in `lib/index.js` before the `npm install` step. Then uncomment it back again, and continue with the rest of the steps (see issue [#563](https://github.com/sass/node-sass/issues/563)).
## Command Line Interface ## Command Line Interface
The interface for command-line usage is fairly simplistic at this stage, as seen in the following usage section. The interface for command-line usage is fairly simplistic at this stage, as seen in the following usage section.
......
...@@ -10,7 +10,7 @@ environment: ...@@ -10,7 +10,7 @@ environment:
- nodejs_version: 0.10 - nodejs_version: 0.10
- nodejs_version: 0.12 - nodejs_version: 0.12
# io.js # io.js
- nodejs_version: "1.1" - nodejs_version: "1.2"
install: install:
- ps: Install-Product node $env:nodejs_version - ps: Install-Product node $env:nodejs_version
......
var semver = require('semver'), var semver = require('semver'),
runtimeVersion = semver.parse(process.version); runtimeVersion = semver.parse(process.version),
fs = require('fs');
/** /**
* Get Runtime Name * Get Runtime Info
* *
* @api private * @api private
*/ */
function getRuntimeName() { function getRuntimeInfo() {
var runtime = process.execPath var execPath = fs.realpathSync(process.execPath); // resolve symbolic link
var runtime = execPath
.split(/[\\/]+/).pop() .split(/[\\/]+/).pop()
.split('.').shift(); .split('.').shift();
return runtime === 'nodejs' ? 'node' : runtime; runtime = runtime === 'nodejs' ? 'node' : runtime;
return {
name: runtime,
execPath: execPath
};
} }
/** /**
...@@ -24,10 +32,10 @@ function getRuntimeName() { ...@@ -24,10 +32,10 @@ function getRuntimeName() {
function getBinaryIdentifiableName() { function getBinaryIdentifiableName() {
return [process.platform, '-', return [process.platform, '-',
process.arch, '-', process.arch, '-',
getRuntimeName(), '-', process.runtime.name, '-',
runtimeVersion.major, '.', runtimeVersion.major, '.',
runtimeVersion.minor].join(''); runtimeVersion.minor].join('');
} }
process.runtime = getRuntimeName(); process.runtime = getRuntimeInfo();
process.sassBinaryName = getBinaryIdentifiableName(); process.sassBinaryName = getBinaryIdentifiableName();
var fs = require('fs'), var fs = require('fs'),
path = require('path'); path = require('path'),
util = require('util');
require('./extensions'); require('./extensions');
...@@ -146,12 +147,9 @@ function getOptions(options) { ...@@ -146,12 +147,9 @@ function getOptions(options) {
var error = options.error; var error = options.error;
var success = options.success; var success = options.success;
options.error = function(err, code) { options.error = function(err) {
err = JSON.parse(err);
err.code = code;
if (error) { if (error) {
error(err); error(util._extend(new Error(), JSON.parse(err)));
} }
}; };
...@@ -246,6 +244,8 @@ module.exports.renderSync = function(options) { ...@@ -246,6 +244,8 @@ module.exports.renderSync = function(options) {
return result; return result;
} }
throw util._extend(new Error(), JSON.parse(result.error));
}; };
/** /**
......
...@@ -50,7 +50,11 @@ function afterBuild(options) { ...@@ -50,7 +50,11 @@ function afterBuild(options) {
*/ */
function build(options) { function build(options) {
var proc = spawn(process.execPath, ['node_modules/pangyp/bin/node-gyp', 'rebuild'].concat(options.args), { var arguments = ['node_modules/pangyp/bin/node-gyp', 'rebuild'].concat(options.args);
console.log(['Building:', process.runtime.execPath].concat(arguments).join(' '));
var proc = spawn(process.runtime.execPath, arguments, {
stdio: [0, 1, 2] stdio: [0, 1, 2]
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment