Skip to content

Commit

Permalink
Replace shellwords with 3rd-party module
Browse files Browse the repository at this point in the history
  • Loading branch information
ixti committed Jul 24, 2012
1 parent fe3a4ef commit a84b6c8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 29 deletions.
4 changes: 2 additions & 2 deletions bin/mincer.js
Expand Up @@ -9,12 +9,12 @@ var path = require('path');


// 3rd-party
var ArgumentParser = require('argparse').ArgumentParser;
var ArgumentParser = require('argparse').ArgumentParser;
var shellwords = require('shellwords').split;


// internal
var Mincer = require('..');
var shellwords = require('../lib/mincer/common').shellwords;


////////////////////////////////////////////////////////////////////////////////
Expand Down
23 changes: 0 additions & 23 deletions lib/mincer/common.js
Expand Up @@ -46,29 +46,6 @@ module.exports.normalizeExtension = function (extension) {



// parse string in a BASH style
// inspired by Shellwords module of Ruby
var SHELLWORDS_PATTERN = /\s*(?:([^\s\\\'\"]+)|'((?:[^\'\\]|\\.)*)'|"((?:[^\"\\]|\\.)*)")/;
module.exports.shellwords = function (line) {
var words = [], match, field;

while (line) {
match = SHELLWORDS_PATTERN.exec(line);

if (!match || !match[0]) {
line = false;
} else {
line = line.substr(match[0].length);
field = (match[1] || match[2] || match[3] || '').replace(/\\(.)/, '$1');

words.push(field);
}
}

return words;
};


// Dummy alternative to Ruby's Pathname#is_absolute
var ABSOLUTE_PATH_PATTERN = /^\//;
module.exports.isAbsolute = function (pathname) {
Expand Down
6 changes: 3 additions & 3 deletions lib/mincer/processors/directive_processor.js
Expand Up @@ -31,15 +31,15 @@ var path = require('path');


// 3rd-party
var _ = require('underscore');
var async = require('async');
var _ = require('underscore');
var async = require('async');
var shellwords = require('shellwords').split;


// internal
var Template = require('../template');
var prop = require('../common').prop;
var getter = require('../common').getter;
var shellwords = require('../common').shellwords;
var isAbsolute = require('../common').isAbsolute;
var isRelative = require('../common').isRelative;

Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -22,7 +22,8 @@
"argparse" : "~ 0.1.3",
"fs-tools" : "~ 0.2.2",
"async" : "~ 0.1.22",
"underscore" : "~ 1.3.3"
"underscore" : "~ 1.3.3",
"shellwords" : "~ 0.1.0"
},
"devDependencies" : { "mocha": "~> 1.3.0" },
"engines" : { "node": ">= 0.6.0" }
Expand Down

0 comments on commit a84b6c8

Please sign in to comment.