node-sass
Advanced tools
Comparing version 0.9.3 to 0.9.4-rc1
142
lib/cli.js
@@ -5,6 +5,8 @@ var watch = require('node-watch'), | ||
Emitter = require('events').EventEmitter, | ||
stdin = require('get-stdin'), | ||
cwd = process.cwd(); | ||
var optimist = require('optimist') | ||
var yargs = require('yargs') | ||
.usage('Compile .scss files with node-sass.\nUsage: $0 [options] <input.scss> [<output.css>]') | ||
.version(require('../package.json').version, 'version').alias('version', 'V') | ||
.options('output-style', { | ||
@@ -35,3 +37,4 @@ describe: 'CSS output style (nested|expanded|compact|compressed)', | ||
describe: 'Watch a directory or file', | ||
alias: 'w' | ||
alias: 'w', | ||
type: 'boolean' | ||
}) | ||
@@ -43,4 +46,10 @@ .options('output', { | ||
.options('stdout', { | ||
describe: 'Print the resulting CSS to stdout' | ||
describe: 'Print the resulting CSS to stdout', | ||
type: 'boolean' | ||
}) | ||
.options('omit-source-map-url', { | ||
describe: 'Omit source map URL comment from output', | ||
type: 'boolean', | ||
alias: 'x' | ||
}) | ||
.options('help', { | ||
@@ -51,5 +60,7 @@ describe: 'Print usage info', | ||
}) | ||
.check(function(argv){ | ||
.check(function(argv) { | ||
if (argv.help) { return true; } | ||
if (argv._.length < 1) { return false; } | ||
if (!argv._.length && (process.stdin.isTTY || process.env.isTTY)) { | ||
return false; | ||
} | ||
}); | ||
@@ -62,2 +73,3 @@ | ||
var args = Array.prototype.slice.call(arguments, 1); | ||
return function() { | ||
@@ -76,35 +88,3 @@ var self = this; | ||
exports = module.exports = function(args) { | ||
var argv = optimist.parse(args); | ||
if (argv.help) { | ||
optimist.showHelp(); | ||
process.exit(0); | ||
return; | ||
} | ||
var emitter = new Emitter(); | ||
emitter.on('error', function(err){ | ||
console.error(err); | ||
process.exit(1); | ||
}); | ||
var options = { | ||
stdout: argv.stdout | ||
}; | ||
var inFile = options.inFile = argv._[0]; | ||
var outFile = options.outFile = argv.o || argv._[1]; | ||
if (!outFile) { | ||
var suffix = '.css'; | ||
if (/\.css$/.test(inFile)) { | ||
suffix = ''; | ||
} | ||
outFile = options.outFile = path.join(cwd, path.basename(inFile, '.scss') + suffix); | ||
} | ||
// make sure it's an array. | ||
options.includePaths = argv['include-path']; | ||
function run(options, emitter) { | ||
if (!Array.isArray(options.includePaths)) { | ||
@@ -114,7 +94,2 @@ options.includePaths = [options.includePaths]; | ||
// include the image path. | ||
options.imagePath = argv['image-path']; | ||
// if it's an array, make it a string | ||
options.outputStyle = argv['output-style']; | ||
if (Array.isArray(options.outputStyle)) { | ||
@@ -124,4 +99,2 @@ options.outputStyle = options.outputStyle[0]; | ||
// if it's an array, make it a string | ||
options.sourceComments = argv['source-comments']; | ||
if (Array.isArray(options.sourceComments)) { | ||
@@ -131,23 +104,20 @@ options.sourceComments = options.sourceComments[0]; | ||
// Set the sourceMap path if the sourceComment was 'map', but set source-map was missing | ||
if (options.sourceComments === 'map' && !argv['source-map']) { | ||
argv['source-map'] = true; | ||
if (options.sourceComments === 'map' && !options.sourceMap) { | ||
options.sourceMap = true; | ||
} | ||
// set source map file and set sourceComments to 'map' | ||
if (argv['source-map']) { | ||
if (options.sourceMap) { | ||
options.sourceComments = 'map'; | ||
if (argv['source-map'] === true) { | ||
options.sourceMap = outFile + '.map'; | ||
if (options.sourceMap === true) { | ||
options.sourceMap = options.dest + '.map'; | ||
} else { | ||
options.sourceMap = path.resolve(cwd, argv['source-map']); | ||
options.sourceMap = path.resolve(cwd, options.sourceMap); | ||
} | ||
} | ||
options.precision = argv.precision; | ||
if (options.watch) { | ||
var throttledRender = throttle(render, options, emitter); | ||
var watchDir = options.watch; | ||
if (argv.w) { | ||
var watchDir = argv.w; | ||
if (watchDir === true) { | ||
@@ -158,8 +128,8 @@ watchDir = []; | ||
} | ||
watchDir.push(inFile); | ||
var throttledRender = throttle(render, options, emitter); | ||
watchDir.push(options.src); | ||
watch(watchDir, function(file){ | ||
watch(watchDir, function(file) { | ||
emitter.emit('warn', '=> changed: '.grey + file.blue); | ||
if (isSassFile(file)) { | ||
@@ -171,10 +141,56 @@ throttledRender(); | ||
throttledRender(); | ||
} else { | ||
render(options, emitter); | ||
} | ||
} | ||
module.exports = function(args) { | ||
var argv = yargs.parse(args); | ||
var emitter = new Emitter(); | ||
var options = { | ||
imagePath: argv['image-path'], | ||
includePaths: argv['include-path'], | ||
omitSourceMapUrl: argv['omit-source-map-url'], | ||
outputStyle: argv['output-style'], | ||
precision: argv.precision, | ||
sourceComments: argv['source-comments'], | ||
sourceMap: argv['source-map'], | ||
stdout: argv.stdout, | ||
watch: argv.w | ||
}; | ||
if (argv.help) { | ||
yargs.showHelp(); | ||
process.exit(); | ||
return; | ||
} | ||
emitter.on('error', function(err) { | ||
console.error(err); | ||
process.exit(1); | ||
}); | ||
options.src = argv._[0]; | ||
options.dest = argv.o || argv._[1]; | ||
if (!options.dest) { | ||
var suffix = '.css'; | ||
if (/\.css$/.test(options.src)) { | ||
suffix = ''; | ||
} | ||
options.dest = path.join(cwd, path.basename(options.src, '.scss') + suffix); | ||
} | ||
if (process.stdin.isTTY || process.env.isTTY) { | ||
run(options, emitter); | ||
} else { | ||
stdin(function(data) { | ||
options.data = data; | ||
run(options, emitter); | ||
}); | ||
} | ||
return emitter; | ||
}; | ||
exports.optimist = optimist; | ||
module.exports.yargs = yargs; |
@@ -6,51 +6,61 @@ var sass = require('../sass'), | ||
function render(options, emitter) { | ||
sass.render({ | ||
file: options.inFile, | ||
var renderOptions = { | ||
imagePath: options.imagePath, | ||
includePaths: options.includePaths, | ||
imagePath: options.imagePath, | ||
omitSourceMapUrl: options.omitSourceMapUrl, | ||
outFile: options.outFile, | ||
outputStyle: options.outputStyle, | ||
precision: options.precision, | ||
sourceComments: options.sourceComments, | ||
sourceMap: options.sourceMap, | ||
precision: options.precision, | ||
success: function(css, sourceMap) { | ||
sourceMap: options.sourceMap | ||
}; | ||
var todo = 1; | ||
var done = function() { | ||
if (--todo <= 0) { | ||
emitter.emit('done'); | ||
} | ||
}; | ||
if (options.src) { | ||
renderOptions.file = options.src; | ||
} else if (options.data) { | ||
renderOptions.data = options.data; | ||
} | ||
emitter.emit('warn', chalk.green('Rendering Complete, saving .css file...')); | ||
renderOptions.success = function(css, sourceMap) { | ||
var todo = 1; | ||
var done = function() { | ||
if (--todo <= 0) { | ||
emitter.emit('done'); | ||
} | ||
}; | ||
fs.writeFile(options.outFile, css, function(err) { | ||
if (err) { return emitter.emit('error', chalk.red('Error: ' + err)); } | ||
emitter.emit('warn', chalk.green('Wrote CSS to ' + options.outFile)); | ||
emitter.emit('write', err, options.outFile, css); | ||
if (options.stdout || (!process.stdout.isTTY && !process.env.isTTY)) { | ||
emitter.emit('log', css); | ||
return done(); | ||
} | ||
emitter.emit('warn', chalk.green('Rendering Complete, saving .css file...')); | ||
fs.writeFile(options.dest, css, function(err) { | ||
if (err) { return emitter.emit('error', chalk.red('Error: ' + err)); } | ||
emitter.emit('warn', chalk.green('Wrote CSS to ' + options.dest)); | ||
emitter.emit('write', err, options.dest, css); | ||
done(); | ||
}); | ||
if (options.sourceMap) { | ||
todo++; | ||
fs.writeFile(options.sourceMap, sourceMap, function(err) { | ||
if (err) {return emitter.emit('error', chalk.red('Error' + err)); } | ||
emitter.emit('warn', chalk.green('Wrote Source Map to ' + options.sourceMap)); | ||
emitter.emit('write-source-map', err, options.sourceMap, sourceMap); | ||
done(); | ||
}); | ||
} | ||
if (options.sourceMap) { | ||
todo++; | ||
fs.writeFile(options.sourceMap, sourceMap, function(err) { | ||
if (err) {return emitter.emit('error', chalk.red('Error' + err)); } | ||
emitter.emit('warn', chalk.green('Wrote Source Map to ' + options.sourceMap)); | ||
emitter.emit('write-source-map', err, options.sourceMap, sourceMap); | ||
done(); | ||
}); | ||
} | ||
emitter.emit('render', css); | ||
}; | ||
if (options.stdout) { | ||
emitter.emit('log', css); | ||
} | ||
renderOptions.error = function(error) { | ||
emitter.emit('error', chalk.red(error)); | ||
}; | ||
emitter.emit('render', css); | ||
}, | ||
error: function(error) { | ||
emitter.emit('error', chalk.red(error)); | ||
} | ||
}); | ||
sass.render(renderOptions); | ||
} | ||
module.exports = render; |
@@ -6,10 +6,10 @@ Libsass | ||
[![Build Status](https://travis-ci.org/hcatlin/libsass.png?branch=master)](https://travis-ci.org/hcatlin/libsass) | ||
[![Build Status](https://travis-ci.org/sass/libsass.png?branch=master)](https://travis-ci.org/sass/libsass) [![Bountysource](https://www.bountysource.com/badge/tracker?tracker_id=283068)](https://www.bountysource.com/trackers/283068-libsass?utm_source=283068&utm_medium=shield&utm_campaign=TRACKER_BADGE) | ||
http://github.com/sass/libsass | ||
https://github.com/sass/libsass | ||
Libsass is just a library, but if you want to RUN libsass, | ||
then go to http://github.com/hcatlin/sassc or | ||
http://github.com/hcatlin/sassruby or | ||
[find your local implementer](https://github.com/hcatlin/libsass/wiki/Implementations). | ||
then go to https://github.com/sass/sassc or | ||
https://github.com/sass/ruby-libsass or | ||
[find your local implementer](https://github.com/sass/libsass/wiki/Implementations). | ||
@@ -40,3 +40,3 @@ About | ||
Since libsass is a pure library, tests are run through the [SassSpec](http://github.com/hcatlin/sass-spec) project using the [SassC](http://github.com/hcatlin/sassc) driver. | ||
Since libsass is a pure library, tests are run through the [SassSpec](https://github.com/sass/sass-spec) project using the [SassC](http://github.com/sass/sassc) driver. | ||
@@ -96,3 +96,3 @@ To run tests against libsass while developing, you can run `./script/spec`. This will clone SassC and Sass-Spec under the project folder and then run the Sass-Spec test suite. You may want to update the clones to ensure you have the latest version. | ||
Hampton Catlin ([@hcatlin]). The extension and continuing evolution | ||
of the language has all been the result of years of work by Nathan | ||
of the language has all been the result of years of work by Natalie | ||
Weizenbaum ([@nex3]) and Chris Eppstein ([@chriseppstein]). | ||
@@ -112,7 +112,7 @@ | ||
[@hcatlin]: http://github.com/hcatlin | ||
[@akhleung]: http://github.com/akhleung | ||
[@chriseppstein]: http://github.com/chriseppstein | ||
[@nex3]: http://github.com/nex3 | ||
[@hcatlin]: https://github.com/hcatlin | ||
[@akhleung]: https://github.com/akhleung | ||
[@chriseppstein]: https://github.com/chriseppstein | ||
[@nex3]: https://github.com/nex3 | ||
[sass_interface.h]: sass_interface.h |
sass2scss | ||
========= | ||
[![Build Status](https://travis-ci.org/mgreter/sass2scss.svg?branch=master)](https://travis-ci.org/mgreter/sass2scss) | ||
It may just work or is probably horribly broken! | ||
C++ port of https://github.com/mgreter/OCBNET-CSS3/blob/master/bin/sass2scss. | ||
This implementation is currently far ahead of the previous perl implementation! | ||
C++ port of https://github.com/mgreter/OCBNET-CSS3/blob/master/bin/sass2scss. | ||
This implementation is currently far ahead of the previous perl implementation! | ||
@@ -14,9 +16,4 @@ Converts old indented sass syntax to newer scss syntax. My C++ is very rusty so it may | ||
Added some unit tests for sass2scss to https://github.com/mgreter/CSS-Sass. | ||
This may hopefully will get integrated to https://github.com/hcatlin/libsass. | ||
Added some unit tests for sass2scss to https://github.com/mgreter/CSS-Sass. | ||
-> https://github.com/hcatlin/libsass/pull/181 | ||
-> https://github.com/hcatlin/libsass/issues/16 | ||
Options | ||
@@ -31,2 +28,7 @@ ======= | ||
-p, --pretty pretty print output | ||
-c, --convert convert src comments | ||
-s, --strip strip all comments | ||
-k, --keep keep all comments | ||
-h, --help help text | ||
-v, --version version information | ||
``` |
@@ -5,3 +5,3 @@ { | ||
"description": "wrapper around libsass", | ||
"version": "0.9.3", | ||
"version": "0.9.4-rc1", | ||
"homepage": "https://github.com/sass/node-sass", | ||
@@ -45,16 +45,19 @@ "keywords": [ | ||
"mocha": "~1.18.2", | ||
"nan": "~1.0.0", | ||
"nan": "~1.3.0", | ||
"node-watch": "~0.3.4", | ||
"object-assign": "^0.3.1", | ||
"optimist": "~0.6.1", | ||
"shelljs": "~0.2.6", | ||
"sinon": "~1.9.1", | ||
"node-sass-middleware": "~0.2.0" | ||
"node-sass-middleware": "~0.2.0", | ||
"yargs": "~1.3.1", | ||
"get-stdin": "~3.0.0" | ||
}, | ||
"devDependencies": { | ||
"coveralls": "~2.10.0", | ||
"jscoverage": "~0.3.8", | ||
"jshint": "~2.5.0", | ||
"mocha-lcov-reporter": "~0.0.1" | ||
"coveralls": "^2.11.1", | ||
"cross-spawn": "^0.2.3", | ||
"jscoverage": "^0.5.6", | ||
"jshint": "^2.5.5", | ||
"mocha-lcov-reporter": "^0.0.1", | ||
"object-assign": "^0.3.1" | ||
} | ||
} |
@@ -156,4 +156,12 @@ # node-sass | ||
## Connect/Express middleware | ||
## Integrations | ||
Listing of community uses of node-sass in build tools and frameworks. | ||
### Brunch plugin | ||
[Brunch](http://brunch.io)'s official sass plugin uses node-sass by default, and automatically falls back to ruby if use of Compass is detected: <https://github.com/brunch/sass-brunch> | ||
### Connect/Express middleware | ||
Recompile `.scss` files automatically for connect and express based http servers | ||
@@ -176,27 +184,32 @@ | ||
## DocPad Plugin | ||
### DocPad Plugin | ||
[@jking90](https://github.com/jking90) wrote a [DocPad](http://docpad.org/) plugin that compiles `.scss` files using node-sass: <https://github.com/jking90/docpad-plugin-nodesass> | ||
## Grunt extension | ||
### Duo.js extension | ||
[@stephenway](https://github.com/stephenway) has created an extension that transpiles Sass to CSS using node-sass with [duo.js](http://duojs.org/) | ||
<https://github.com/duojs/sass> | ||
### Grunt extension | ||
[@sindresorhus](https://github.com/sindresorhus/) has created a set of grunt tasks based on node-sass: <https://github.com/sindresorhus/grunt-sass> | ||
## Gulp extension | ||
### Gulp extension | ||
[@dlmanning](https://github.com/dlmanning/) has created a gulp sass plugin based on node-sass: <https://github.com/dlmanning/gulp-sass> | ||
## Harp | ||
### Harp | ||
[@sintaxi](https://github.com/sintaxi)’s Harp web server implicitly compiles `.scss` files using node-sass: <https://github.com/sintaxi/harp> | ||
## Metalsmith plugin | ||
### Metalsmith plugin | ||
[@stevenschobert](https://github.com/stevenschobert/) has created a metalsmith plugin based on node-sass: <https://github.com/stevenschobert/metalsmith-sass> | ||
## Meteor plugin | ||
### Meteor plugin | ||
[@fourseven](https://github.com/fourseven) has created a meteor plugin based on node-sass: <https://github.com/fourseven/meteor-scss> | ||
## Mimosa module | ||
### Mimosa module | ||
@@ -207,3 +220,3 @@ [@dbashford](https://github.com/dbashford) has created a Mimosa module for sass which includes node-sass: <https://github.com/dbashford/mimosa-sass> | ||
There is also an example connect app here: <https://github.com/sass/node-sass-example> | ||
There is also an example connect app here: <https://github.com/andrew/node-sass-example> | ||
@@ -218,2 +231,3 @@ ## Rebuilding binaries | ||
cd node-sass | ||
git submodule update --init --recursive | ||
npm install | ||
@@ -220,0 +234,0 @@ npm install -g node-gyp |
23
sass.js
@@ -8,3 +8,4 @@ var path = require('path'); | ||
var candidates = [ | ||
[__dirname, 'build', 'Release', 'obj.target', 'binding.node'], | ||
[__dirname, 'build', 'Release', 'binding.node'], | ||
[__dirname, 'build', 'Debug', 'binding.node'], | ||
[__dirname, 'bin', process.platform + '-' + process.arch + '-' + v8, 'binding.node'] | ||
@@ -46,2 +47,3 @@ ]; | ||
var sourceComments; | ||
var sourceMap; | ||
@@ -54,5 +56,19 @@ options = options || {}; | ||
sourceComments = options.source_comments || options.sourceComments; | ||
if (options.sourceMap && !sourceComments) { | ||
sourceComments = 'map'; | ||
} | ||
if (typeof options.outFile === 'string' && typeof options.file === 'string' && path.resolve(options.outFile) === path.normalize(options.outFile).replace(new RegExp(path.sep + '$'), '' )) { | ||
options.outFile = path.resolve(path.dirname(options.file), options.outFile); | ||
} | ||
sourceMap = options.sourceMap; | ||
if ((typeof sourceMap !== 'string' || !sourceMap.trim()) && sourceComments === 'map') { | ||
sourceMap = options.outFile !== null ? options.outFile + '.map' : ''; | ||
} else if (options.outFile && sourceMap) { | ||
sourceMap = path.resolve(path.dirname(options.file), sourceMap); | ||
} | ||
prepareStats(options, stats); | ||
@@ -68,4 +84,5 @@ | ||
comments: SASS_SOURCE_COMMENTS[sourceComments] || 0, | ||
omitSourceMapUrl: options.omitSourceMapUrl, | ||
stats: stats, | ||
sourceMap: options.sourceMap, | ||
sourceMap: sourceMap, | ||
precision: parseInt(options.precision) || 5, | ||
@@ -157,3 +174,3 @@ success: function onSuccess(css, sourceMap) { | ||
if (options.sourceMap === true) { | ||
options.sourceMap = path.basename(options.outFile) + '.map'; | ||
options.sourceMap = options.outFile + '.map'; | ||
} | ||
@@ -160,0 +177,0 @@ options.success = function(css, sourceMap) { |
130
test/cli.js
@@ -5,4 +5,5 @@ var path = require('path'), | ||
exec = require('child_process').exec, | ||
spawn = require('cross-spawn'), | ||
assign = require('object-assign'), | ||
cli = process.env.NODESASS_COVERAGE ? require('../lib-coverage/cli') : require('../lib/cli'), | ||
cliPath = path.resolve(__dirname, '../bin/node-sass'), | ||
@@ -31,6 +32,26 @@ sampleFilename = path.resolve(__dirname, 'sample.scss'); | ||
var sampleScssPath = path.join(__dirname, 'sample.scss'); | ||
var sampleCssOutputPath = path.join(__dirname, '../sample.css'); | ||
var sampleCssMapOutputPath = path.join(__dirname, '../sample.css.map'); | ||
describe('cli', function() { | ||
it('should read data from stdin', function(done) { | ||
var src = fs.createReadStream(sampleScssPath); | ||
var emitter = spawn(cliPath, ['--stdout']); | ||
emitter.stdout.on('data', function(data) { | ||
data = data.toString().trim(); | ||
assert.equal(data, expectedSampleNoComments.trim()); | ||
done(); | ||
}); | ||
src.pipe(emitter.stdin); | ||
}); | ||
it('should print help when run with no arguments', function(done) { | ||
exec('node ' + cliPath, function(err, stdout, stderr) { | ||
done(assert(stderr.indexOf('Compile .scss files with node-sass') === 0)); | ||
var env = assign(process.env, { isTTY: true }); | ||
exec('node ' + cliPath, { | ||
env: env | ||
}, function(err, stdout, stderr) { | ||
done(assert(stderr.trim().indexOf('Compile .scss files with node-sass') === 0)); | ||
}); | ||
@@ -40,6 +61,8 @@ }); | ||
it('should compile sample.scss as sample.css', function(done) { | ||
var env = assign(process.env, { isTTY: true }); | ||
var resultPath = path.join(__dirname, 'sample.css'); | ||
exec('node ' + cliPath + ' ' + sampleFilename, { | ||
cwd: __dirname | ||
cwd: __dirname, | ||
env: env | ||
}, function(err) { | ||
@@ -56,6 +79,8 @@ assert.equal(err, null); | ||
it('should compile sample.scss to ../out.css', function(done) { | ||
var env = assign(process.env, { isTTY: true }); | ||
var resultPath = path.resolve(__dirname, '../out.css'); | ||
exec('node ' + cliPath + ' ' + sampleFilename + ' ../out.css', { | ||
cwd: __dirname | ||
cwd: __dirname, | ||
env: env | ||
}, function(err) { | ||
@@ -71,3 +96,3 @@ assert.equal(err, null); | ||
it('should compile with --include-path option', function(done){ | ||
it('should compile with --include-path option', function(done) { | ||
var emitter = cli([ | ||
@@ -79,3 +104,3 @@ '--include-path', path.join(__dirname, 'lib'), | ||
emitter.on('error', done); | ||
emitter.on('write', function(err, file, css){ | ||
emitter.on('write', function(err, file, css) { | ||
assert.equal(css.trim(), 'body {\n background: red;\n color: #0000fe; }'); | ||
@@ -86,6 +111,6 @@ fs.unlink(file, done); | ||
it('should compile with the --output-style', function(done){ | ||
var emitter = cli(['--output-style', 'compressed', path.join(__dirname, 'sample.scss')]); | ||
it('should compile with the --output-style', function(done) { | ||
var emitter = cli(['--output-style', 'compressed', sampleScssPath]); | ||
emitter.on('error', done); | ||
emitter.on('write', function(err, file, css){ | ||
emitter.on('write', function(err, file, css) { | ||
assert.equal(css, expectedSampleCompressed); | ||
@@ -96,6 +121,6 @@ fs.unlink(file, done); | ||
it('should compile with the --source-comments option', function(done){ | ||
var emitter = cli(['--source-comments', 'none', path.join(__dirname, 'sample.scss')]); | ||
it('should compile with the --source-comments option', function(done) { | ||
var emitter = cli(['--source-comments', 'none', sampleScssPath]); | ||
emitter.on('error', done); | ||
emitter.on('write', function(err, file, css){ | ||
emitter.on('write', function(err, file, css) { | ||
assert.equal(css, expectedSampleNoComments); | ||
@@ -106,6 +131,6 @@ fs.unlink(file, done); | ||
it('should compile with the --image-path option', function(done){ | ||
it('should compile with the --image-path option', function(done) { | ||
var emitter = cli(['--image-path', '/path/to/images', path.join(__dirname, 'image_path.scss')]); | ||
emitter.on('error', done); | ||
emitter.on('write', function(err, file, css){ | ||
emitter.on('write', function(err, file, css) { | ||
assert.equal(css, expectedSampleCustomImagePath); | ||
@@ -116,7 +141,7 @@ fs.unlink(file, done); | ||
it('should write the output to the file specified with the --output option', function(done){ | ||
it('should write the output to the file specified with the --output option', function(done) { | ||
var resultPath = path.join(__dirname, '../output.css'); | ||
var emitter = cli(['--output', resultPath, path.join(__dirname, 'sample.scss')]); | ||
var emitter = cli(['--output', resultPath, sampleScssPath]); | ||
emitter.on('error', done); | ||
emitter.on('write', function(){ | ||
emitter.on('write', function() { | ||
fs.exists(resultPath, function(exists) { | ||
@@ -129,7 +154,50 @@ assert(exists); | ||
it('should compile with the --source-map option', function(done){ | ||
var emitter = cli([path.join(__dirname, 'sample.scss'), '--source-map']); | ||
it('should write to stdout with the --stdout option', function(done) { | ||
var emitter = cli(['--stdout', sampleScssPath]); | ||
emitter.on('error', done); | ||
emitter.on('log', function(css) { | ||
assert.equal(css, expectedSampleNoComments); | ||
done(); | ||
}); | ||
}); | ||
it('should not write to disk with the --stdout option', function(done) { | ||
var emitter = cli(['--stdout', sampleScssPath]); | ||
emitter.on('error', done); | ||
emitter.on('done', function() { | ||
fs.exists(sampleCssOutputPath, function(exists) { | ||
assert(!exists); | ||
if (exists) {fs.unlinkSync(sampleCssOutputPath);} | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('should not exit with the --watch option', function(done) { | ||
var command = cliPath + ' --watch ' + sampleScssPath; | ||
var env = assign(process.env, { isTTY: true }); | ||
var child = exec('node ' + command, { | ||
env: env | ||
}); | ||
var exited = false; | ||
child.on('exit', function() { | ||
exited = true; | ||
}); | ||
setTimeout(function() { | ||
if (exited){ | ||
throw new Error('Watch ended too early!'); | ||
} else { | ||
child.kill(); | ||
done(); | ||
} | ||
}, 100); | ||
}); | ||
it('should compile with the --source-map option', function(done) { | ||
var emitter = cli([sampleScssPath, '--source-map']); | ||
emitter.on('error', done); | ||
emitter.on('write-source-map', function(err, file) { | ||
assert.equal(file, path.join(__dirname, '../sample.css.map')); | ||
assert.equal(file, sampleCssMapOutputPath); | ||
fs.exists(file, function(exists) { | ||
@@ -139,5 +207,6 @@ assert(exists); | ||
}); | ||
emitter.on('done', function() { | ||
fs.unlink(path.join(__dirname, '../sample.css.map'), function() { | ||
fs.unlink(path.join(__dirname, '../sample.css'), function() { | ||
fs.unlink(sampleCssMapOutputPath, function() { | ||
fs.unlink(sampleCssOutputPath, function() { | ||
done(); | ||
@@ -150,3 +219,3 @@ }); | ||
it('should compile with the --source-map option with specific filename', function(done){ | ||
var emitter = cli([path.join(__dirname, 'sample.scss'), '--source-map', path.join(__dirname, '../sample.map')]); | ||
var emitter = cli([sampleScssPath, '--source-map', path.join(__dirname, '../sample.map')]); | ||
emitter.on('error', done); | ||
@@ -161,3 +230,3 @@ emitter.on('write-source-map', function(err, file) { | ||
fs.unlink(path.join(__dirname, '../sample.map'), function() { | ||
fs.unlink(path.join(__dirname, '../sample.css'), function() { | ||
fs.unlink(sampleCssOutputPath, function() { | ||
done(); | ||
@@ -169,7 +238,7 @@ }); | ||
it('should compile a sourceMap if --source-comments="map", but the --source-map option is excluded', function(done){ | ||
var emitter = cli([path.join(__dirname, 'sample.scss'), '--source-comments', 'map']); | ||
it('should compile a sourceMap if --source-comments="map", but the --source-map option is excluded', function(done) { | ||
var emitter = cli([sampleScssPath, '--source-comments', 'map']); | ||
emitter.on('error', done); | ||
emitter.on('write-source-map', function(err, file) { | ||
assert.equal(file, path.join(__dirname, '../sample.css.map')); | ||
assert.equal(file, sampleCssMapOutputPath); | ||
fs.exists(file, function(exists) { | ||
@@ -180,4 +249,4 @@ assert(exists); | ||
emitter.on('done', function() { | ||
fs.unlink(path.join(__dirname, '../sample.css.map'), function() { | ||
fs.unlink(path.join(__dirname, '../sample.css'), function() { | ||
fs.unlink(sampleCssMapOutputPath, function() { | ||
fs.unlink(sampleCssOutputPath, function() { | ||
done(); | ||
@@ -188,3 +257,2 @@ }); | ||
}); | ||
}); |
var sass = require('../sass'); | ||
var assert = require('assert'); | ||
var sampleFilename = require('path').resolve(__dirname, 'sample.scss'); | ||
var sampleFilename = require('path').resolve(__dirname, 'sample.scss').replace(/\\/g, '/'); | ||
@@ -6,0 +6,0 @@ var expectedCommentsScssStr = '/* line 1, ' + sampleFilename + ' */\n\ |
@@ -6,5 +6,5 @@ 'use strict'; | ||
var sass = process.env.NODESASS_COVERAGE ? require('../sass-coverage') : require('../sass'); | ||
var includedFilesFile = path.resolve(__dirname, 'included_files.scss'); | ||
var sampleFile = path.resolve(__dirname, 'sample.scss'); | ||
var imagePathFile = path.resolve(__dirname, 'image_path.scss'); | ||
var includedFilesFile = path.resolve(__dirname, 'included_files.scss').replace(/\\/g, '/'); | ||
var sampleFile = path.resolve(__dirname, 'sample.scss').replace(/\\/g, '/'); | ||
var imagePathFile = path.resolve(__dirname, 'image_path.scss').replace(/\\/g, '/'); | ||
var sample = require('./sample.js'); | ||
@@ -161,2 +161,2 @@ | ||
}); | ||
}); |
@@ -263,2 +263,22 @@ var sass = process.env.NODESASS_COVERAGE ? require('../sass-coverage') : require('../sass'); | ||
it('should save source paths relative to the sourceMap file', function(done) { | ||
var includedFilesFile = path.resolve(__dirname, 'included_files.scss'); | ||
var relativeOutFile = path.resolve(__dirname, 'some_path/out.scss'); | ||
sass.renderFile({ | ||
file: includedFilesFile, | ||
outFile: relativeOutFile, | ||
sourceMap: true, | ||
success: function (cssFile, sourceMapFile) { | ||
var mapObject = JSON.parse(filesWritten[sourceMapFile]); | ||
assert.ok(mapObject.sources.indexOf('../included_files.scss') > -1); | ||
assert.ok(mapObject.sources.indexOf('../sample.scss') > -1); | ||
assert.ok(mapObject.sources.indexOf('../image_path.scss') > -1); | ||
done(); | ||
}, | ||
error: function (error) { | ||
done(error); | ||
} | ||
}); | ||
}); | ||
}); | ||
@@ -265,0 +285,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances 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
6265660
151
1185
286
11
6
17
+ Addedget-stdin@~3.0.0
+ Addedyargs@~1.3.1
+ Addedansi-regex@0.2.1(transitive)
+ Addedansi-styles@1.1.0(transitive)
+ Addedchalk@0.5.1(transitive)
+ Addedcommander@2.3.0(transitive)
+ Addeddebug@2.0.0(transitive)
+ Addeddiff@1.0.8(transitive)
+ Addedescape-string-regexp@1.0.2(transitive)
+ Addedget-stdin@3.0.2(transitive)
+ Addedgrowl@1.8.1(transitive)
+ Addedhas-ansi@0.1.0(transitive)
+ Addedminimist@0.0.8(transitive)
+ Addedmkdirp@0.5.0(transitive)
+ Addedmocha@1.21.5(transitive)
+ Addedms@0.6.2(transitive)
+ Addednan@1.3.0(transitive)
+ Addednode-sass@0.9.6(transitive)
+ Addednode-sass-middleware@0.3.1(transitive)
+ Addedobject-assign@1.0.0(transitive)
+ Addedshelljs@0.3.0(transitive)
+ Addedsinon@1.10.3(transitive)
+ Addedstrip-ansi@0.3.0(transitive)
+ Addedsupports-color@0.2.0(transitive)
+ Addedyargs@1.3.3(transitive)
- Removedoptimist@~0.6.1
- Removedminimist@0.0.10(transitive)
- Removednan@1.0.0(transitive)
- Removedoptimist@0.6.1(transitive)
- Removedwordwrap@0.0.3(transitive)
Updatednan@~1.3.0