Commit cfa43416 by SebastianOsuna

Output directory is created if it doesn't exists.

parent 15ea512d
var fs = require('fs'),
chalk = require('chalk'),
sass = require('./');
sass = require('./'),
path = require('path'),
mkdirp = require('mkdirp');
/**
* Render
......@@ -47,14 +49,20 @@ module.exports = function(options, emitter) {
emitter.emit('warn', chalk.green('Rendering Complete, saving .css file...'));
fs.writeFile(options.dest, result.css, function(err) {
mkdirp(path.dirname(options.dest), function(err) {
if (err) {
return emitter.emit('error', chalk.red(err));
}
emitter.emit('warn', chalk.green('Wrote CSS to ' + options.dest));
emitter.emit('write', err, options.dest, result.css);
done();
fs.writeFile(options.dest, result.css, function (err) {
if (err) {
return emitter.emit('error', chalk.red(err));
}
emitter.emit('warn', chalk.green('Wrote CSS to ' + options.dest));
emitter.emit('write', err, options.dest, result.css);
done();
});
});
if (options.sourceMap) {
......
......@@ -225,6 +225,26 @@ describe('cli', function() {
});
});
describe('node-sass in.scss --output path/to/file/out.css', function() {
it('should create the output directory', function(done) {
var src = fixture('output-directory/index.scss');
var dest = fixture('output-directory/path/to/file/index.css');
var bin = spawn(cli, [src, '--output', path.dirname(dest)]);
bin.on('close', function() {
assert(fs.existsSync(path.dirname(dest)));
fs.unlinkSync(dest);
fs.rmdirSync(path.dirname(dest));
dest = path.dirname(dest);
fs.rmdirSync(path.dirname(dest));
dest = path.dirname(dest);
fs.rmdirSync(path.dirname(dest));
done();
});
});
});
describe('importer', function() {
var dest = fixture('include-files/index.css');
var src = fixture('include-files/index.scss');
......
#navbar {
width: 80%;
height: 23px;
}
#navbar ul {
list-style-type: none;
}
#navbar li {
float: left;
a {
font-weight: bold;
}
}
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