This commit is contained in:
chrosey
2017-09-13 07:52:34 +02:00
parent a1f16c37f4
commit 2340b0226b
24621 changed files with 2912161 additions and 149 deletions
+1
View File
@@ -0,0 +1 @@
node_modules
+42
View File
@@ -0,0 +1,42 @@
{spawn, exec} = require "child_process"
watch = require "nodewatch"
task "spec", "Runs the Jasmine specs.", ->
header()
jasmine = spawn "node", ["node_modules/jasmine-node/lib/jasmine-node/cli.js", "--coffee", "-i", "src", "spec"]
jasmine.stdout.on "data", (data) ->
process.stdout.write data
jasmine.stderr.on "data", (data) ->
process.stderr.write data
jasmine.stdin.end()
task "watch", "Watches for file changes, recompiling CoffeeScript and running the Jasmine specs.", ->
console.log "Watching Shellwords for changes...\n"
invoke "spec"
watch.add("src").add("spec").onChange (file, prev, cur) ->
exec "coffee -co lib src", (error, stdout, stderr) ->
throw error if error
invoke "spec"
header = ->
divider = "------------"
console.log divider, dateString(), divider
dateString = ->
d = new Date
h = d.getHours()
m = d.getMinutes()
s = d.getSeconds()
meridiem = if h >= 12 then "PM" else "AM"
h -= 12 if h > 12
h = 12 if h is 0
m = "0" + m if m < 10
s = "0" + s if s < 10
"#{d.toLocaleDateString()} #{h}:#{m}:#{s} #{meridiem}"
+19
View File
@@ -0,0 +1,19 @@
Copyright (C) 2011 by Jimmy Cuadra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+19
View File
@@ -0,0 +1,19 @@
# Shellwords
Shellwords provides functions to manipulate strings according to the word parsing rules of the UNIX Bourne shell. It is based on [the Ruby module of the same name](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/shellwords/rdoc/Shellwords.html).
## Installation
Add "shellwords" to your `package.json` file and run `npm install`.
## Example
``` javascript
var shellwords = require("shellwords");
shellwords.split("foo 'bar baz'");
// ["foo", "bar baz"]
shellwords.escape("What's up, yo?");
// 'What\\\'s\\ up,\\ yo\\?'
```
+57
View File
@@ -0,0 +1,57 @@
// Generated by CoffeeScript 1.3.3
(function() {
var scan;
scan = function(string, pattern, callback) {
var match, result;
result = "";
while (string.length > 0) {
match = string.match(pattern);
if (match) {
result += string.slice(0, match.index);
result += callback(match);
string = string.slice(match.index + match[0].length);
} else {
result += string;
string = "";
}
}
return result;
};
exports.split = function(line) {
var field, words;
if (line == null) {
line = "";
}
words = [];
field = "";
scan(line, /\s*(?:([^\s\\\'\"]+)|'((?:[^\'\\]|\\.)*)'|"((?:[^\"\\]|\\.)*)"|(\\.?)|(\S))(\s|$)?/, function(match) {
var dq, escape, garbage, raw, seperator, sq, word;
raw = match[0], word = match[1], sq = match[2], dq = match[3], escape = match[4], garbage = match[5], seperator = match[6];
if (garbage != null) {
throw new Error("Unmatched quote");
}
field += word || (sq || dq || escape).replace(/\\(?=.)/, "");
if (seperator != null) {
words.push(field);
return field = "";
}
});
if (field) {
words.push(field);
}
return words;
};
exports.escape = function(str) {
if (str == null) {
str = "";
}
if (str == null) {
return "''";
}
return str.replace(/([^A-Za-z0-9_\-.,:\/@\n])/g, "\\$1").replace(/\n/g, "'\n'");
};
}).call(this);
+76
View File
@@ -0,0 +1,76 @@
{
"_args": [
[
{
"raw": "shellwords@^0.1.0",
"scope": null,
"escapedName": "shellwords",
"name": "shellwords",
"rawSpec": "^0.1.0",
"spec": ">=0.1.0 <0.2.0",
"type": "range"
},
"c:\\xampp\\htdocs\\laravel\\node_modules\\node-notifier"
]
],
"_from": "shellwords@>=0.1.0 <0.2.0",
"_id": "shellwords@0.1.0",
"_inCache": true,
"_location": "/shellwords",
"_phantomChildren": {},
"_requested": {
"raw": "shellwords@^0.1.0",
"scope": null,
"escapedName": "shellwords",
"name": "shellwords",
"rawSpec": "^0.1.0",
"spec": ">=0.1.0 <0.2.0",
"type": "range"
},
"_requiredBy": [
"/node-notifier"
],
"_resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.0.tgz",
"_shasum": "66afd47b6a12932d9071cbfd98a52e785cd0ba14",
"_shrinkwrap": null,
"_spec": "shellwords@^0.1.0",
"_where": "c:\\xampp\\htdocs\\laravel\\node_modules\\node-notifier",
"author": {
"name": "Jimmy Cuadra",
"email": "jimmy@jimmycuadra.com",
"url": "http://jimmycuadra.com/"
},
"bugs": {
"url": "https://github.com/jimmycuadra/shellwords/issues"
},
"dependencies": {},
"description": "Manipulate strings according to the word parsing rules of the UNIX Bourne shell.",
"devDependencies": {
"jasmine-node": "~1.0.26",
"nodewatch": "~0.1.0"
},
"directories": {},
"dist": {
"shasum": "66afd47b6a12932d9071cbfd98a52e785cd0ba14",
"tarball": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.0.tgz"
},
"homepage": "https://github.com/jimmycuadra/shellwords",
"main": "./lib/shellwords",
"maintainers": [
{
"name": "jimmycuadra",
"email": "jimmycuadra@gmail.com"
}
],
"name": "shellwords",
"optionalDependencies": {},
"readme": "# Shellwords\n\nShellwords provides functions to manipulate strings according to the word parsing rules of the UNIX Bourne shell. It is based on [the Ruby module of the same name](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/shellwords/rdoc/Shellwords.html).\n\n## Installation\n\nAdd \"shellwords\" to your `package.json` file and run `npm install`.\n\n## Example\n\n``` javascript\nvar shellwords = require(\"shellwords\");\n\nshellwords.split(\"foo 'bar baz'\");\n// [\"foo\", \"bar baz\"]\n\nshellwords.escape(\"What's up, yo?\");\n// 'What\\\\\\'s\\\\ up,\\\\ yo\\\\?'\n```\n",
"repository": {
"type": "git",
"url": "git://github.com/jimmycuadra/shellwords.git"
},
"scripts": {
"test": "cake spec"
},
"version": "0.1.0"
}
+55
View File
@@ -0,0 +1,55 @@
shellwords = require "../src/shellwords"
describe "Shellwords", ->
describe "#split", ->
it "splits normal words", ->
results = shellwords.split "foo bar baz"
(expect results).toEqual ["foo", "bar", "baz"]
it "splits single quoted phrases", ->
results = shellwords.split "foo 'bar baz'"
(expect results).toEqual ["foo", "bar baz"]
it "splits double quoted phrases", ->
results = shellwords.split '"foo bar" baz'
(expect results).toEqual ["foo bar", "baz"]
it "respects escaped characters", ->
results = shellwords.split "foo\\ bar baz"
(expect results).toEqual ["foo bar", "baz"]
it "respects escaped characters within single quotes", ->
results = shellwords.split "foo 'bar\\ baz'"
(expect results).toEqual ["foo", "bar baz"]
it "respects escaped characters within double quotes", ->
results = shellwords.split 'foo "bar\\ baz"'
(expect results).toEqual ["foo", "bar baz"]
it "respects escaped quotes within quotes", ->
results = shellwords.split 'foo "bar\\" baz"'
(expect results).toEqual ['foo', 'bar" baz']
results = shellwords.split "foo 'bar\\' baz'"
(expect results).toEqual ["foo", "bar' baz"]
it "throws on unmatched single quotes", ->
fn = ->
shellwords.split "foo 'bar baz"
(expect fn).toThrow()
it "throws on unmatched double quotes", ->
fn = ->
shellwords.split 'foo "bar baz'
(expect fn).toThrow()
describe "#escape", ->
it "escapes a string to be safe for shell command line", ->
results = shellwords.escape "foo '\"' bar"
(expect results).toEqual "foo\\ \\'\\\"\\'\\ bar"
it "dummy escapes any multibyte chars", ->
results = shellwords.escape "あい"
(expect results).toEqual "\\\\"
+53
View File
@@ -0,0 +1,53 @@
scan = (string, pattern, callback) ->
result = ""
while string.length > 0
match = string.match pattern
if match
result += string.slice 0, match.index
result += callback match
string = string.slice(match.index + match[0].length)
else
result += string
string = ""
result
exports.split = (line = "") ->
words = []
field = ""
scan line, ///
\s* # Leading whitespace
(?: #
([^\s\\\'\"]+) # Normal words
| #
'((?:[^\'\\]|\\.)*)' # Stuff in single quotes
| #
"((?:[^\"\\]|\\.)*)" # Stuff in double quotes
| #
(\\.?) # Escaped character
| #
(\S) # Garbage
) #
(\s|$)? # Seperator
///, (match) ->
[raw, word, sq, dq, escape, garbage, seperator] = match
throw new Error "Unmatched quote" if garbage?
field += (word or (sq or dq or escape).replace(/\\(?=.)/, ""))
if seperator?
words.push field
field = ""
words.push field if field
words
exports.escape = (str = "") ->
return "''" unless str?
str.replace(/([^A-Za-z0-9_\-.,:\/@\n])/g, "\\$1").replace(/\n/g, "'\n'")