From f8edd2013e39b05ce974c2563bea46c747dbeccc Mon Sep 17 00:00:00 2001 From: Adeel Date: Wed, 14 Jan 2015 12:52:11 +0200 Subject: [PATCH 1/2] CLI: Simplifies path resolution for dest. * Attempts to address #621. --- bin/node-sass | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/bin/node-sass b/bin/node-sass index 52c591ee3..15b9252ff 100755 --- a/bin/node-sass +++ b/bin/node-sass @@ -126,20 +126,10 @@ function getEmitter() { */ function getOptions(args, options) { - var dir = options.output || process.cwd(); + var dir = options.output ? path.resolve(process.cwd(), options.output) : process.cwd(); options.src = args[0]; - options.dest = null; - - if (args[1]) { // destination is available - // now first check if the destination is absolute path - // see http://stackoverflow.com/a/24225816/863980 for Marc Diethelm's comment - if (path.resolve(args[1]) === path.normalize(args[1]).replace(/(.+)([\/|\\])$/, '$1')) { - options.dest = args[1]; - } else { // since dest path is relative, resolve it w.r.t input - options.dest = path.join(dir, args[1]); - } - } + options.dest = args[1] ? path.resolve(dir, args[1]) : undefined; if (!options.dest && !options.stdout) { var ext = path.extname(options.src); @@ -204,7 +194,7 @@ function run(options, emitter) { } if (options.sourceMap) { - if (options.sourceMap === true) { + if (options.sourceMap === 'true') { options.sourceMap = options.dest + '.map'; } else { options.sourceMap = path.resolve(process.cwd(), options.sourceMap); From 6ef18f817bfb614b9a70253f850187485cb26fe9 Mon Sep 17 00:00:00 2001 From: Adeel Date: Wed, 14 Jan 2015 17:22:05 +0200 Subject: [PATCH 2/2] CLI: Adds a test for output as argument. --- test/cli.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/cli.js b/test/cli.js index 05071259d..022eef705 100644 --- a/test/cli.js +++ b/test/cli.js @@ -95,6 +95,21 @@ describe('cli', function() { }); }); + it('should compile a scss file to custom destination', function(done) { + process.chdir(fixture('simple')); + + var src = fixture('simple/index.scss'); + var dest = fixture('simple/index-custom.css'); + var bin = spawn(cli, [src, dest]); + + bin.on('close', function() { + assert(fs.existsSync(dest)); + fs.unlinkSync(dest); + process.chdir(__dirname); + done(); + }); + }); + it('should compile with the --include-path option', function(done) { var includePaths = [ '--include-path', fixture('include-path/functions'),