신동해

Add list.ejs, Update server.js

Showing 132 changed files with 4757 additions and 0 deletions
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + exec "$basedir/node" "$basedir/../ejs/bin/cli.js" "$@"
10 +else
11 + exec node "$basedir/../ejs/bin/cli.js" "$@"
12 +fi
1 +@ECHO off
2 +GOTO start
3 +:find_dp0
4 +SET dp0=%~dp0
5 +EXIT /b
6 +:start
7 +SETLOCAL
8 +CALL :find_dp0
9 +
10 +IF EXIST "%dp0%\node.exe" (
11 + SET "_prog=%dp0%\node.exe"
12 +) ELSE (
13 + SET "_prog=node"
14 + SET PATHEXT=%PATHEXT:;.JS;=;%
15 +)
16 +
17 +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\ejs\bin\cli.js" %*
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + # Support pipeline input
13 + if ($MyInvocation.ExpectingInput) {
14 + $input | & "$basedir/node$exe" "$basedir/../ejs/bin/cli.js" $args
15 + } else {
16 + & "$basedir/node$exe" "$basedir/../ejs/bin/cli.js" $args
17 + }
18 + $ret=$LASTEXITCODE
19 +} else {
20 + # Support pipeline input
21 + if ($MyInvocation.ExpectingInput) {
22 + $input | & "node$exe" "$basedir/../ejs/bin/cli.js" $args
23 + } else {
24 + & "node$exe" "$basedir/../ejs/bin/cli.js" $args
25 + }
26 + $ret=$LASTEXITCODE
27 +}
28 +exit $ret
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + exec "$basedir/node" "$basedir/../jake/bin/cli.js" "$@"
10 +else
11 + exec node "$basedir/../jake/bin/cli.js" "$@"
12 +fi
1 +@ECHO off
2 +GOTO start
3 +:find_dp0
4 +SET dp0=%~dp0
5 +EXIT /b
6 +:start
7 +SETLOCAL
8 +CALL :find_dp0
9 +
10 +IF EXIST "%dp0%\node.exe" (
11 + SET "_prog=%dp0%\node.exe"
12 +) ELSE (
13 + SET "_prog=node"
14 + SET PATHEXT=%PATHEXT:;.JS;=;%
15 +)
16 +
17 +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\jake\bin\cli.js" %*
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + # Support pipeline input
13 + if ($MyInvocation.ExpectingInput) {
14 + $input | & "$basedir/node$exe" "$basedir/../jake/bin/cli.js" $args
15 + } else {
16 + & "$basedir/node$exe" "$basedir/../jake/bin/cli.js" $args
17 + }
18 + $ret=$LASTEXITCODE
19 +} else {
20 + # Support pipeline input
21 + if ($MyInvocation.ExpectingInput) {
22 + $input | & "node$exe" "$basedir/../jake/bin/cli.js" $args
23 + } else {
24 + & "node$exe" "$basedir/../jake/bin/cli.js" $args
25 + }
26 + $ret=$LASTEXITCODE
27 +}
28 +exit $ret
...@@ -16,11 +16,32 @@ ...@@ -16,11 +16,32 @@
16 "node": ">= 0.6" 16 "node": ">= 0.6"
17 } 17 }
18 }, 18 },
19 + "node_modules/ansi-styles": {
20 + "version": "3.2.1",
21 + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
22 + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
23 + "dependencies": {
24 + "color-convert": "^1.9.0"
25 + },
26 + "engines": {
27 + "node": ">=4"
28 + }
29 + },
19 "node_modules/array-flatten": { 30 "node_modules/array-flatten": {
20 "version": "1.1.1", 31 "version": "1.1.1",
21 "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", 32 "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
22 "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" 33 "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
23 }, 34 },
35 + "node_modules/async": {
36 + "version": "0.9.2",
37 + "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz",
38 + "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0="
39 + },
40 + "node_modules/balanced-match": {
41 + "version": "1.0.2",
42 + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
43 + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
44 + },
24 "node_modules/bl": { 45 "node_modules/bl": {
25 "version": "2.2.1", 46 "version": "2.2.1",
26 "resolved": "https://registry.npmjs.org/bl/-/bl-2.2.1.tgz", 47 "resolved": "https://registry.npmjs.org/bl/-/bl-2.2.1.tgz",
...@@ -50,6 +71,15 @@ ...@@ -50,6 +71,15 @@
50 "node": ">= 0.8" 71 "node": ">= 0.8"
51 } 72 }
52 }, 73 },
74 + "node_modules/brace-expansion": {
75 + "version": "1.1.11",
76 + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
77 + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
78 + "dependencies": {
79 + "balanced-match": "^1.0.0",
80 + "concat-map": "0.0.1"
81 + }
82 + },
53 "node_modules/bson": { 83 "node_modules/bson": {
54 "version": "1.1.6", 84 "version": "1.1.6",
55 "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.6.tgz", 85 "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.6.tgz",
...@@ -66,6 +96,37 @@ ...@@ -66,6 +96,37 @@
66 "node": ">= 0.8" 96 "node": ">= 0.8"
67 } 97 }
68 }, 98 },
99 + "node_modules/chalk": {
100 + "version": "2.4.2",
101 + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
102 + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
103 + "dependencies": {
104 + "ansi-styles": "^3.2.1",
105 + "escape-string-regexp": "^1.0.5",
106 + "supports-color": "^5.3.0"
107 + },
108 + "engines": {
109 + "node": ">=4"
110 + }
111 + },
112 + "node_modules/color-convert": {
113 + "version": "1.9.3",
114 + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
115 + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
116 + "dependencies": {
117 + "color-name": "1.1.3"
118 + }
119 + },
120 + "node_modules/color-name": {
121 + "version": "1.1.3",
122 + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
123 + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
124 + },
125 + "node_modules/concat-map": {
126 + "version": "0.0.1",
127 + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
128 + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
129 + },
69 "node_modules/content-disposition": { 130 "node_modules/content-disposition": {
70 "version": "0.5.3", 131 "version": "0.5.3",
71 "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", 132 "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz",
...@@ -137,6 +198,20 @@ ...@@ -137,6 +198,20 @@
137 "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", 198 "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
138 "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" 199 "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
139 }, 200 },
201 + "node_modules/ejs": {
202 + "version": "3.1.6",
203 + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.6.tgz",
204 + "integrity": "sha512-9lt9Zse4hPucPkoP7FHDF0LQAlGyF9JVpnClFLFH3aSSbxmyoqINRpp/9wePWJTUl4KOQwRL72Iw3InHPDkoGw==",
205 + "dependencies": {
206 + "jake": "^10.6.1"
207 + },
208 + "bin": {
209 + "ejs": "bin/cli.js"
210 + },
211 + "engines": {
212 + "node": ">=0.10.0"
213 + }
214 + },
140 "node_modules/encodeurl": { 215 "node_modules/encodeurl": {
141 "version": "1.0.2", 216 "version": "1.0.2",
142 "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", 217 "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
...@@ -150,6 +225,14 @@ ...@@ -150,6 +225,14 @@
150 "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", 225 "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
151 "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" 226 "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
152 }, 227 },
228 + "node_modules/escape-string-regexp": {
229 + "version": "1.0.5",
230 + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
231 + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
232 + "engines": {
233 + "node": ">=0.8.0"
234 + }
235 + },
153 "node_modules/etag": { 236 "node_modules/etag": {
154 "version": "1.8.1", 237 "version": "1.8.1",
155 "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", 238 "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
...@@ -198,6 +281,14 @@ ...@@ -198,6 +281,14 @@
198 "node": ">= 0.10.0" 281 "node": ">= 0.10.0"
199 } 282 }
200 }, 283 },
284 + "node_modules/filelist": {
285 + "version": "1.0.2",
286 + "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.2.tgz",
287 + "integrity": "sha512-z7O0IS8Plc39rTCq6i6iHxk43duYOn8uFJiWSewIq0Bww1RNybVHSCjahmcC87ZqAm4OTvFzlzeGu3XAzG1ctQ==",
288 + "dependencies": {
289 + "minimatch": "^3.0.4"
290 + }
291 + },
201 "node_modules/finalhandler": { 292 "node_modules/finalhandler": {
202 "version": "1.1.2", 293 "version": "1.1.2",
203 "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", 294 "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz",
...@@ -231,6 +322,14 @@ ...@@ -231,6 +322,14 @@
231 "node": ">= 0.6" 322 "node": ">= 0.6"
232 } 323 }
233 }, 324 },
325 + "node_modules/has-flag": {
326 + "version": "3.0.0",
327 + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
328 + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
329 + "engines": {
330 + "node": ">=4"
331 + }
332 + },
234 "node_modules/http-errors": { 333 "node_modules/http-errors": {
235 "version": "1.7.2", 334 "version": "1.7.2",
236 "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", 335 "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
...@@ -275,6 +374,23 @@ ...@@ -275,6 +374,23 @@
275 "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", 374 "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
276 "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" 375 "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
277 }, 376 },
377 + "node_modules/jake": {
378 + "version": "10.8.2",
379 + "resolved": "https://registry.npmjs.org/jake/-/jake-10.8.2.tgz",
380 + "integrity": "sha512-eLpKyrfG3mzvGE2Du8VoPbeSkRry093+tyNjdYaBbJS9v17knImYGNXQCUV0gLxQtF82m3E8iRb/wdSQZLoq7A==",
381 + "dependencies": {
382 + "async": "0.9.x",
383 + "chalk": "^2.4.2",
384 + "filelist": "^1.0.1",
385 + "minimatch": "^3.0.4"
386 + },
387 + "bin": {
388 + "jake": "bin/cli.js"
389 + },
390 + "engines": {
391 + "node": "*"
392 + }
393 + },
278 "node_modules/media-typer": { 394 "node_modules/media-typer": {
279 "version": "0.3.0", 395 "version": "0.3.0",
280 "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", 396 "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
...@@ -332,6 +448,17 @@ ...@@ -332,6 +448,17 @@
332 "node": ">= 0.6" 448 "node": ">= 0.6"
333 } 449 }
334 }, 450 },
451 + "node_modules/minimatch": {
452 + "version": "3.0.4",
453 + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
454 + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
455 + "dependencies": {
456 + "brace-expansion": "^1.1.7"
457 + },
458 + "engines": {
459 + "node": "*"
460 + }
461 + },
335 "node_modules/mongodb": { 462 "node_modules/mongodb": {
336 "version": "3.6.4", 463 "version": "3.6.4",
337 "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.4.tgz", 464 "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.4.tgz",
...@@ -587,6 +714,17 @@ ...@@ -587,6 +714,17 @@
587 "safe-buffer": "~5.1.0" 714 "safe-buffer": "~5.1.0"
588 } 715 }
589 }, 716 },
717 + "node_modules/supports-color": {
718 + "version": "5.5.0",
719 + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
720 + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
721 + "dependencies": {
722 + "has-flag": "^3.0.0"
723 + },
724 + "engines": {
725 + "node": ">=4"
726 + }
727 + },
590 "node_modules/toidentifier": { 728 "node_modules/toidentifier": {
591 "version": "1.0.0", 729 "version": "1.0.0",
592 "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", 730 "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
......
1 +'use strict';
2 +const colorConvert = require('color-convert');
3 +
4 +const wrapAnsi16 = (fn, offset) => function () {
5 + const code = fn.apply(colorConvert, arguments);
6 + return `\u001B[${code + offset}m`;
7 +};
8 +
9 +const wrapAnsi256 = (fn, offset) => function () {
10 + const code = fn.apply(colorConvert, arguments);
11 + return `\u001B[${38 + offset};5;${code}m`;
12 +};
13 +
14 +const wrapAnsi16m = (fn, offset) => function () {
15 + const rgb = fn.apply(colorConvert, arguments);
16 + return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
17 +};
18 +
19 +function assembleStyles() {
20 + const codes = new Map();
21 + const styles = {
22 + modifier: {
23 + reset: [0, 0],
24 + // 21 isn't widely supported and 22 does the same thing
25 + bold: [1, 22],
26 + dim: [2, 22],
27 + italic: [3, 23],
28 + underline: [4, 24],
29 + inverse: [7, 27],
30 + hidden: [8, 28],
31 + strikethrough: [9, 29]
32 + },
33 + color: {
34 + black: [30, 39],
35 + red: [31, 39],
36 + green: [32, 39],
37 + yellow: [33, 39],
38 + blue: [34, 39],
39 + magenta: [35, 39],
40 + cyan: [36, 39],
41 + white: [37, 39],
42 + gray: [90, 39],
43 +
44 + // Bright color
45 + redBright: [91, 39],
46 + greenBright: [92, 39],
47 + yellowBright: [93, 39],
48 + blueBright: [94, 39],
49 + magentaBright: [95, 39],
50 + cyanBright: [96, 39],
51 + whiteBright: [97, 39]
52 + },
53 + bgColor: {
54 + bgBlack: [40, 49],
55 + bgRed: [41, 49],
56 + bgGreen: [42, 49],
57 + bgYellow: [43, 49],
58 + bgBlue: [44, 49],
59 + bgMagenta: [45, 49],
60 + bgCyan: [46, 49],
61 + bgWhite: [47, 49],
62 +
63 + // Bright color
64 + bgBlackBright: [100, 49],
65 + bgRedBright: [101, 49],
66 + bgGreenBright: [102, 49],
67 + bgYellowBright: [103, 49],
68 + bgBlueBright: [104, 49],
69 + bgMagentaBright: [105, 49],
70 + bgCyanBright: [106, 49],
71 + bgWhiteBright: [107, 49]
72 + }
73 + };
74 +
75 + // Fix humans
76 + styles.color.grey = styles.color.gray;
77 +
78 + for (const groupName of Object.keys(styles)) {
79 + const group = styles[groupName];
80 +
81 + for (const styleName of Object.keys(group)) {
82 + const style = group[styleName];
83 +
84 + styles[styleName] = {
85 + open: `\u001B[${style[0]}m`,
86 + close: `\u001B[${style[1]}m`
87 + };
88 +
89 + group[styleName] = styles[styleName];
90 +
91 + codes.set(style[0], style[1]);
92 + }
93 +
94 + Object.defineProperty(styles, groupName, {
95 + value: group,
96 + enumerable: false
97 + });
98 +
99 + Object.defineProperty(styles, 'codes', {
100 + value: codes,
101 + enumerable: false
102 + });
103 + }
104 +
105 + const ansi2ansi = n => n;
106 + const rgb2rgb = (r, g, b) => [r, g, b];
107 +
108 + styles.color.close = '\u001B[39m';
109 + styles.bgColor.close = '\u001B[49m';
110 +
111 + styles.color.ansi = {
112 + ansi: wrapAnsi16(ansi2ansi, 0)
113 + };
114 + styles.color.ansi256 = {
115 + ansi256: wrapAnsi256(ansi2ansi, 0)
116 + };
117 + styles.color.ansi16m = {
118 + rgb: wrapAnsi16m(rgb2rgb, 0)
119 + };
120 +
121 + styles.bgColor.ansi = {
122 + ansi: wrapAnsi16(ansi2ansi, 10)
123 + };
124 + styles.bgColor.ansi256 = {
125 + ansi256: wrapAnsi256(ansi2ansi, 10)
126 + };
127 + styles.bgColor.ansi16m = {
128 + rgb: wrapAnsi16m(rgb2rgb, 10)
129 + };
130 +
131 + for (let key of Object.keys(colorConvert)) {
132 + if (typeof colorConvert[key] !== 'object') {
133 + continue;
134 + }
135 +
136 + const suite = colorConvert[key];
137 +
138 + if (key === 'ansi16') {
139 + key = 'ansi';
140 + }
141 +
142 + if ('ansi16' in suite) {
143 + styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
144 + styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
145 + }
146 +
147 + if ('ansi256' in suite) {
148 + styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
149 + styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
150 + }
151 +
152 + if ('rgb' in suite) {
153 + styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
154 + styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
155 + }
156 + }
157 +
158 + return styles;
159 +}
160 +
161 +// Make the export immutable
162 +Object.defineProperty(module, 'exports', {
163 + enumerable: true,
164 + get: assembleStyles
165 +});
1 +MIT License
2 +
3 +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4 +
5 +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:
6 +
7 +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 +
9 +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.
1 +{
2 + "name": "ansi-styles",
3 + "version": "3.2.1",
4 + "description": "ANSI escape codes for styling strings in the terminal",
5 + "license": "MIT",
6 + "repository": "chalk/ansi-styles",
7 + "author": {
8 + "name": "Sindre Sorhus",
9 + "email": "sindresorhus@gmail.com",
10 + "url": "sindresorhus.com"
11 + },
12 + "engines": {
13 + "node": ">=4"
14 + },
15 + "scripts": {
16 + "test": "xo && ava",
17 + "screenshot": "svg-term --command='node screenshot' --out=screenshot.svg --padding=3 --width=55 --height=3 --at=1000 --no-cursor"
18 + },
19 + "files": [
20 + "index.js"
21 + ],
22 + "keywords": [
23 + "ansi",
24 + "styles",
25 + "color",
26 + "colour",
27 + "colors",
28 + "terminal",
29 + "console",
30 + "cli",
31 + "string",
32 + "tty",
33 + "escape",
34 + "formatting",
35 + "rgb",
36 + "256",
37 + "shell",
38 + "xterm",
39 + "log",
40 + "logging",
41 + "command-line",
42 + "text"
43 + ],
44 + "dependencies": {
45 + "color-convert": "^1.9.0"
46 + },
47 + "devDependencies": {
48 + "ava": "*",
49 + "babel-polyfill": "^6.23.0",
50 + "svg-term-cli": "^2.1.1",
51 + "xo": "*"
52 + },
53 + "ava": {
54 + "require": "babel-polyfill"
55 + }
56 +}
1 +# ansi-styles [![Build Status](https://travis-ci.org/chalk/ansi-styles.svg?branch=master)](https://travis-ci.org/chalk/ansi-styles)
2 +
3 +> [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
4 +
5 +You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
6 +
7 +<img src="https://cdn.rawgit.com/chalk/ansi-styles/8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">
8 +
9 +
10 +## Install
11 +
12 +```
13 +$ npm install ansi-styles
14 +```
15 +
16 +
17 +## Usage
18 +
19 +```js
20 +const style = require('ansi-styles');
21 +
22 +console.log(`${style.green.open}Hello world!${style.green.close}`);
23 +
24 +
25 +// Color conversion between 16/256/truecolor
26 +// NOTE: If conversion goes to 16 colors or 256 colors, the original color
27 +// may be degraded to fit that color palette. This means terminals
28 +// that do not support 16 million colors will best-match the
29 +// original color.
30 +console.log(style.bgColor.ansi.hsl(120, 80, 72) + 'Hello world!' + style.bgColor.close);
31 +console.log(style.color.ansi256.rgb(199, 20, 250) + 'Hello world!' + style.color.close);
32 +console.log(style.color.ansi16m.hex('#ABCDEF') + 'Hello world!' + style.color.close);
33 +```
34 +
35 +## API
36 +
37 +Each style has an `open` and `close` property.
38 +
39 +
40 +## Styles
41 +
42 +### Modifiers
43 +
44 +- `reset`
45 +- `bold`
46 +- `dim`
47 +- `italic` *(Not widely supported)*
48 +- `underline`
49 +- `inverse`
50 +- `hidden`
51 +- `strikethrough` *(Not widely supported)*
52 +
53 +### Colors
54 +
55 +- `black`
56 +- `red`
57 +- `green`
58 +- `yellow`
59 +- `blue`
60 +- `magenta`
61 +- `cyan`
62 +- `white`
63 +- `gray` ("bright black")
64 +- `redBright`
65 +- `greenBright`
66 +- `yellowBright`
67 +- `blueBright`
68 +- `magentaBright`
69 +- `cyanBright`
70 +- `whiteBright`
71 +
72 +### Background colors
73 +
74 +- `bgBlack`
75 +- `bgRed`
76 +- `bgGreen`
77 +- `bgYellow`
78 +- `bgBlue`
79 +- `bgMagenta`
80 +- `bgCyan`
81 +- `bgWhite`
82 +- `bgBlackBright`
83 +- `bgRedBright`
84 +- `bgGreenBright`
85 +- `bgYellowBright`
86 +- `bgBlueBright`
87 +- `bgMagentaBright`
88 +- `bgCyanBright`
89 +- `bgWhiteBright`
90 +
91 +
92 +## Advanced usage
93 +
94 +By default, you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
95 +
96 +- `style.modifier`
97 +- `style.color`
98 +- `style.bgColor`
99 +
100 +###### Example
101 +
102 +```js
103 +console.log(style.color.green.open);
104 +```
105 +
106 +Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `style.codes`, which returns a `Map` with the open codes as keys and close codes as values.
107 +
108 +###### Example
109 +
110 +```js
111 +console.log(style.codes.get(36));
112 +//=> 39
113 +```
114 +
115 +
116 +## [256 / 16 million (TrueColor) support](https://gist.github.com/XVilka/8346728)
117 +
118 +`ansi-styles` uses the [`color-convert`](https://github.com/Qix-/color-convert) package to allow for converting between various colors and ANSI escapes, with support for 256 and 16 million colors.
119 +
120 +To use these, call the associated conversion function with the intended output, for example:
121 +
122 +```js
123 +style.color.ansi.rgb(100, 200, 15); // RGB to 16 color ansi foreground code
124 +style.bgColor.ansi.rgb(100, 200, 15); // RGB to 16 color ansi background code
125 +
126 +style.color.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
127 +style.bgColor.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
128 +
129 +style.color.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color foreground code
130 +style.bgColor.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color background code
131 +```
132 +
133 +
134 +## Related
135 +
136 +- [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal
137 +
138 +
139 +## Maintainers
140 +
141 +- [Sindre Sorhus](https://github.com/sindresorhus)
142 +- [Josh Junon](https://github.com/qix-)
143 +
144 +
145 +## License
146 +
147 +MIT
1 +language: node_js
2 +node_js:
3 + - "0.10"
4 + - "0.12"
5 + - "iojs"
1 +Copyright (c) 2010-2014 Caolan McMahon
2 +
3 +Permission is hereby granted, free of charge, to any person obtaining a copy
4 +of this software and associated documentation files (the "Software"), to deal
5 +in the Software without restriction, including without limitation the rights
6 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 +copies of the Software, and to permit persons to whom the Software is
8 +furnished to do so, subject to the following conditions:
9 +
10 +The above copyright notice and this permission notice shall be included in
11 +all copies or substantial portions of the Software.
12 +
13 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 +THE SOFTWARE.
This diff is collapsed. Click to expand it.
1 +{
2 + "name": "async",
3 + "description": "Higher-order functions and common patterns for asynchronous code",
4 + "version": "0.9.2",
5 + "main": "lib/async.js",
6 + "keywords": [
7 + "async",
8 + "callback",
9 + "utility",
10 + "module"
11 + ],
12 + "license": "MIT",
13 + "repository": {
14 + "type": "git",
15 + "url": "https://github.com/caolan/async.git"
16 + },
17 + "devDependencies": {
18 + "nodeunit": ">0.0.0",
19 + "uglify-js": "1.2.x",
20 + "nodelint": ">0.0.0",
21 + "lodash": ">=2.4.1"
22 + },
23 + "moduleType": [
24 + "amd",
25 + "globals",
26 + "node"
27 + ],
28 + "ignore": [
29 + "**/.*",
30 + "node_modules",
31 + "bower_components",
32 + "test",
33 + "tests"
34 + ],
35 + "authors": [
36 + "Caolan McMahon"
37 + ]
38 +}
...\ No newline at end of file ...\ No newline at end of file
1 +{
2 + "name": "async",
3 + "description": "Higher-order functions and common patterns for asynchronous code",
4 + "version": "0.9.2",
5 + "keywords": [
6 + "async",
7 + "callback",
8 + "utility",
9 + "module"
10 + ],
11 + "license": "MIT",
12 + "repository": "caolan/async",
13 + "scripts": [
14 + "lib/async.js"
15 + ]
16 +}
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
1 +{
2 + "name": "async",
3 + "description": "Higher-order functions and common patterns for asynchronous code",
4 + "main": "lib/async.js",
5 + "author": "Caolan McMahon",
6 + "version": "0.9.2",
7 + "keywords": [
8 + "async",
9 + "callback",
10 + "utility",
11 + "module"
12 + ],
13 + "repository": {
14 + "type": "git",
15 + "url": "https://github.com/caolan/async.git"
16 + },
17 + "bugs": {
18 + "url": "https://github.com/caolan/async/issues"
19 + },
20 + "license": "MIT",
21 + "devDependencies": {
22 + "nodeunit": ">0.0.0",
23 + "uglify-js": "1.2.x",
24 + "nodelint": ">0.0.0",
25 + "lodash": ">=2.4.1"
26 + },
27 + "jam": {
28 + "main": "lib/async.js",
29 + "include": [
30 + "lib/async.js",
31 + "README.md",
32 + "LICENSE"
33 + ],
34 + "categories": [
35 + "Utilities"
36 + ]
37 + },
38 + "scripts": {
39 + "test": "nodeunit test/test-async.js"
40 + },
41 + "spm": {
42 + "main": "lib/async.js"
43 + },
44 + "volo": {
45 + "main": "lib/async.js",
46 + "ignore": [
47 + "**/.*",
48 + "node_modules",
49 + "bower_components",
50 + "test",
51 + "tests"
52 + ]
53 + }
54 +}
...\ No newline at end of file ...\ No newline at end of file
1 +#!/usr/bin/env node
2 +
3 +// This should probably be its own module but complaints about bower/etc.
4 +// support keep coming up and I'd rather just enable the workflow here for now
5 +// and figure out where this should live later. -- @beaugunderson
6 +
7 +var fs = require('fs');
8 +var _ = require('lodash');
9 +
10 +var packageJson = require('../package.json');
11 +
12 +var IGNORES = ['**/.*', 'node_modules', 'bower_components', 'test', 'tests'];
13 +var INCLUDES = ['lib/async.js', 'README.md', 'LICENSE'];
14 +var REPOSITORY_NAME = 'caolan/async';
15 +
16 +packageJson.jam = {
17 + main: packageJson.main,
18 + include: INCLUDES,
19 + categories: ['Utilities']
20 +};
21 +
22 +packageJson.spm = {
23 + main: packageJson.main
24 +};
25 +
26 +packageJson.volo = {
27 + main: packageJson.main,
28 + ignore: IGNORES
29 +};
30 +
31 +var bowerSpecific = {
32 + moduleType: ['amd', 'globals', 'node'],
33 + ignore: IGNORES,
34 + authors: [packageJson.author]
35 +};
36 +
37 +var bowerInclude = ['name', 'description', 'version', 'main', 'keywords',
38 + 'license', 'homepage', 'repository', 'devDependencies'];
39 +
40 +var componentSpecific = {
41 + repository: REPOSITORY_NAME,
42 + scripts: [packageJson.main]
43 +};
44 +
45 +var componentInclude = ['name', 'description', 'version', 'keywords',
46 + 'license'];
47 +
48 +var bowerJson = _.merge({}, _.pick(packageJson, bowerInclude), bowerSpecific);
49 +var componentJson = _.merge({}, _.pick(packageJson, componentInclude), componentSpecific);
50 +
51 +fs.writeFileSync('./bower.json', JSON.stringify(bowerJson, null, 2));
52 +fs.writeFileSync('./component.json', JSON.stringify(componentJson, null, 2));
53 +fs.writeFileSync('./package.json', JSON.stringify(packageJson, null, 2));
1 +tidelift: "npm/balanced-match"
2 +patreon: juliangruber
1 +(MIT)
2 +
3 +Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy of
6 +this software and associated documentation files (the "Software"), to deal in
7 +the Software without restriction, including without limitation the rights to
8 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9 +of the Software, and to permit persons to whom the Software is furnished to do
10 +so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in all
13 +copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 +SOFTWARE.
1 +# balanced-match
2 +
3 +Match balanced string pairs, like `{` and `}` or `<b>` and `</b>`. Supports regular expressions as well!
4 +
5 +[![build status](https://secure.travis-ci.org/juliangruber/balanced-match.svg)](http://travis-ci.org/juliangruber/balanced-match)
6 +[![downloads](https://img.shields.io/npm/dm/balanced-match.svg)](https://www.npmjs.org/package/balanced-match)
7 +
8 +[![testling badge](https://ci.testling.com/juliangruber/balanced-match.png)](https://ci.testling.com/juliangruber/balanced-match)
9 +
10 +## Example
11 +
12 +Get the first matching pair of braces:
13 +
14 +```js
15 +var balanced = require('balanced-match');
16 +
17 +console.log(balanced('{', '}', 'pre{in{nested}}post'));
18 +console.log(balanced('{', '}', 'pre{first}between{second}post'));
19 +console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post'));
20 +```
21 +
22 +The matches are:
23 +
24 +```bash
25 +$ node example.js
26 +{ start: 3, end: 14, pre: 'pre', body: 'in{nested}', post: 'post' }
27 +{ start: 3,
28 + end: 9,
29 + pre: 'pre',
30 + body: 'first',
31 + post: 'between{second}post' }
32 +{ start: 3, end: 17, pre: 'pre', body: 'in{nest}', post: 'post' }
33 +```
34 +
35 +## API
36 +
37 +### var m = balanced(a, b, str)
38 +
39 +For the first non-nested matching pair of `a` and `b` in `str`, return an
40 +object with those keys:
41 +
42 +* **start** the index of the first match of `a`
43 +* **end** the index of the matching `b`
44 +* **pre** the preamble, `a` and `b` not included
45 +* **body** the match, `a` and `b` not included
46 +* **post** the postscript, `a` and `b` not included
47 +
48 +If there's no match, `undefined` will be returned.
49 +
50 +If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `['{', 'a', '']` and `{a}}` will match `['', 'a', '}']`.
51 +
52 +### var r = balanced.range(a, b, str)
53 +
54 +For the first non-nested matching pair of `a` and `b` in `str`, return an
55 +array with indexes: `[ <a index>, <b index> ]`.
56 +
57 +If there's no match, `undefined` will be returned.
58 +
59 +If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `[ 1, 3 ]` and `{a}}` will match `[0, 2]`.
60 +
61 +## Installation
62 +
63 +With [npm](https://npmjs.org) do:
64 +
65 +```bash
66 +npm install balanced-match
67 +```
68 +
69 +## Security contact information
70 +
71 +To report a security vulnerability, please use the
72 +[Tidelift security contact](https://tidelift.com/security).
73 +Tidelift will coordinate the fix and disclosure.
74 +
75 +## License
76 +
77 +(MIT)
78 +
79 +Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
80 +
81 +Permission is hereby granted, free of charge, to any person obtaining a copy of
82 +this software and associated documentation files (the "Software"), to deal in
83 +the Software without restriction, including without limitation the rights to
84 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
85 +of the Software, and to permit persons to whom the Software is furnished to do
86 +so, subject to the following conditions:
87 +
88 +The above copyright notice and this permission notice shall be included in all
89 +copies or substantial portions of the Software.
90 +
91 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
92 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
93 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
94 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
95 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
96 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
97 +SOFTWARE.
1 +'use strict';
2 +module.exports = balanced;
3 +function balanced(a, b, str) {
4 + if (a instanceof RegExp) a = maybeMatch(a, str);
5 + if (b instanceof RegExp) b = maybeMatch(b, str);
6 +
7 + var r = range(a, b, str);
8 +
9 + return r && {
10 + start: r[0],
11 + end: r[1],
12 + pre: str.slice(0, r[0]),
13 + body: str.slice(r[0] + a.length, r[1]),
14 + post: str.slice(r[1] + b.length)
15 + };
16 +}
17 +
18 +function maybeMatch(reg, str) {
19 + var m = str.match(reg);
20 + return m ? m[0] : null;
21 +}
22 +
23 +balanced.range = range;
24 +function range(a, b, str) {
25 + var begs, beg, left, right, result;
26 + var ai = str.indexOf(a);
27 + var bi = str.indexOf(b, ai + 1);
28 + var i = ai;
29 +
30 + if (ai >= 0 && bi > 0) {
31 + if(a===b) {
32 + return [ai, bi];
33 + }
34 + begs = [];
35 + left = str.length;
36 +
37 + while (i >= 0 && !result) {
38 + if (i == ai) {
39 + begs.push(i);
40 + ai = str.indexOf(a, i + 1);
41 + } else if (begs.length == 1) {
42 + result = [ begs.pop(), bi ];
43 + } else {
44 + beg = begs.pop();
45 + if (beg < left) {
46 + left = beg;
47 + right = bi;
48 + }
49 +
50 + bi = str.indexOf(b, i + 1);
51 + }
52 +
53 + i = ai < bi && ai >= 0 ? ai : bi;
54 + }
55 +
56 + if (begs.length) {
57 + result = [ left, right ];
58 + }
59 + }
60 +
61 + return result;
62 +}
1 +{
2 + "name": "balanced-match",
3 + "description": "Match balanced character pairs, like \"{\" and \"}\"",
4 + "version": "1.0.2",
5 + "repository": {
6 + "type": "git",
7 + "url": "git://github.com/juliangruber/balanced-match.git"
8 + },
9 + "homepage": "https://github.com/juliangruber/balanced-match",
10 + "main": "index.js",
11 + "scripts": {
12 + "test": "tape test/test.js",
13 + "bench": "matcha test/bench.js"
14 + },
15 + "devDependencies": {
16 + "matcha": "^0.7.0",
17 + "tape": "^4.6.0"
18 + },
19 + "keywords": [
20 + "match",
21 + "regexp",
22 + "test",
23 + "balanced",
24 + "parse"
25 + ],
26 + "author": {
27 + "name": "Julian Gruber",
28 + "email": "mail@juliangruber.com",
29 + "url": "http://juliangruber.com"
30 + },
31 + "license": "MIT",
32 + "testling": {
33 + "files": "test/*.js",
34 + "browsers": [
35 + "ie/8..latest",
36 + "firefox/20..latest",
37 + "firefox/nightly",
38 + "chrome/25..latest",
39 + "chrome/canary",
40 + "opera/12..latest",
41 + "opera/next",
42 + "safari/5.1..latest",
43 + "ipad/6.0..latest",
44 + "iphone/6.0..latest",
45 + "android-browser/4.2..latest"
46 + ]
47 + }
48 +}
1 +MIT License
2 +
3 +Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in all
13 +copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 +SOFTWARE.
1 +# brace-expansion
2 +
3 +[Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html),
4 +as known from sh/bash, in JavaScript.
5 +
6 +[![build status](https://secure.travis-ci.org/juliangruber/brace-expansion.svg)](http://travis-ci.org/juliangruber/brace-expansion)
7 +[![downloads](https://img.shields.io/npm/dm/brace-expansion.svg)](https://www.npmjs.org/package/brace-expansion)
8 +[![Greenkeeper badge](https://badges.greenkeeper.io/juliangruber/brace-expansion.svg)](https://greenkeeper.io/)
9 +
10 +[![testling badge](https://ci.testling.com/juliangruber/brace-expansion.png)](https://ci.testling.com/juliangruber/brace-expansion)
11 +
12 +## Example
13 +
14 +```js
15 +var expand = require('brace-expansion');
16 +
17 +expand('file-{a,b,c}.jpg')
18 +// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
19 +
20 +expand('-v{,,}')
21 +// => ['-v', '-v', '-v']
22 +
23 +expand('file{0..2}.jpg')
24 +// => ['file0.jpg', 'file1.jpg', 'file2.jpg']
25 +
26 +expand('file-{a..c}.jpg')
27 +// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
28 +
29 +expand('file{2..0}.jpg')
30 +// => ['file2.jpg', 'file1.jpg', 'file0.jpg']
31 +
32 +expand('file{0..4..2}.jpg')
33 +// => ['file0.jpg', 'file2.jpg', 'file4.jpg']
34 +
35 +expand('file-{a..e..2}.jpg')
36 +// => ['file-a.jpg', 'file-c.jpg', 'file-e.jpg']
37 +
38 +expand('file{00..10..5}.jpg')
39 +// => ['file00.jpg', 'file05.jpg', 'file10.jpg']
40 +
41 +expand('{{A..C},{a..c}}')
42 +// => ['A', 'B', 'C', 'a', 'b', 'c']
43 +
44 +expand('ppp{,config,oe{,conf}}')
45 +// => ['ppp', 'pppconfig', 'pppoe', 'pppoeconf']
46 +```
47 +
48 +## API
49 +
50 +```js
51 +var expand = require('brace-expansion');
52 +```
53 +
54 +### var expanded = expand(str)
55 +
56 +Return an array of all possible and valid expansions of `str`. If none are
57 +found, `[str]` is returned.
58 +
59 +Valid expansions are:
60 +
61 +```js
62 +/^(.*,)+(.+)?$/
63 +// {a,b,...}
64 +```
65 +
66 +A comma separated list of options, like `{a,b}` or `{a,{b,c}}` or `{,a,}`.
67 +
68 +```js
69 +/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
70 +// {x..y[..incr]}
71 +```
72 +
73 +A numeric sequence from `x` to `y` inclusive, with optional increment.
74 +If `x` or `y` start with a leading `0`, all the numbers will be padded
75 +to have equal length. Negative numbers and backwards iteration work too.
76 +
77 +```js
78 +/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
79 +// {x..y[..incr]}
80 +```
81 +
82 +An alphabetic sequence from `x` to `y` inclusive, with optional increment.
83 +`x` and `y` must be exactly one character, and if given, `incr` must be a
84 +number.
85 +
86 +For compatibility reasons, the string `${` is not eligible for brace expansion.
87 +
88 +## Installation
89 +
90 +With [npm](https://npmjs.org) do:
91 +
92 +```bash
93 +npm install brace-expansion
94 +```
95 +
96 +## Contributors
97 +
98 +- [Julian Gruber](https://github.com/juliangruber)
99 +- [Isaac Z. Schlueter](https://github.com/isaacs)
100 +
101 +## Sponsors
102 +
103 +This module is proudly supported by my [Sponsors](https://github.com/juliangruber/sponsors)!
104 +
105 +Do you want to support modules like this to improve their quality, stability and weigh in on new features? Then please consider donating to my [Patreon](https://www.patreon.com/juliangruber). Not sure how much of my modules you're using? Try [feross/thanks](https://github.com/feross/thanks)!
106 +
107 +## License
108 +
109 +(MIT)
110 +
111 +Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
112 +
113 +Permission is hereby granted, free of charge, to any person obtaining a copy of
114 +this software and associated documentation files (the "Software"), to deal in
115 +the Software without restriction, including without limitation the rights to
116 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
117 +of the Software, and to permit persons to whom the Software is furnished to do
118 +so, subject to the following conditions:
119 +
120 +The above copyright notice and this permission notice shall be included in all
121 +copies or substantial portions of the Software.
122 +
123 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
124 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
125 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
126 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
127 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
128 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
129 +SOFTWARE.
1 +var concatMap = require('concat-map');
2 +var balanced = require('balanced-match');
3 +
4 +module.exports = expandTop;
5 +
6 +var escSlash = '\0SLASH'+Math.random()+'\0';
7 +var escOpen = '\0OPEN'+Math.random()+'\0';
8 +var escClose = '\0CLOSE'+Math.random()+'\0';
9 +var escComma = '\0COMMA'+Math.random()+'\0';
10 +var escPeriod = '\0PERIOD'+Math.random()+'\0';
11 +
12 +function numeric(str) {
13 + return parseInt(str, 10) == str
14 + ? parseInt(str, 10)
15 + : str.charCodeAt(0);
16 +}
17 +
18 +function escapeBraces(str) {
19 + return str.split('\\\\').join(escSlash)
20 + .split('\\{').join(escOpen)
21 + .split('\\}').join(escClose)
22 + .split('\\,').join(escComma)
23 + .split('\\.').join(escPeriod);
24 +}
25 +
26 +function unescapeBraces(str) {
27 + return str.split(escSlash).join('\\')
28 + .split(escOpen).join('{')
29 + .split(escClose).join('}')
30 + .split(escComma).join(',')
31 + .split(escPeriod).join('.');
32 +}
33 +
34 +
35 +// Basically just str.split(","), but handling cases
36 +// where we have nested braced sections, which should be
37 +// treated as individual members, like {a,{b,c},d}
38 +function parseCommaParts(str) {
39 + if (!str)
40 + return [''];
41 +
42 + var parts = [];
43 + var m = balanced('{', '}', str);
44 +
45 + if (!m)
46 + return str.split(',');
47 +
48 + var pre = m.pre;
49 + var body = m.body;
50 + var post = m.post;
51 + var p = pre.split(',');
52 +
53 + p[p.length-1] += '{' + body + '}';
54 + var postParts = parseCommaParts(post);
55 + if (post.length) {
56 + p[p.length-1] += postParts.shift();
57 + p.push.apply(p, postParts);
58 + }
59 +
60 + parts.push.apply(parts, p);
61 +
62 + return parts;
63 +}
64 +
65 +function expandTop(str) {
66 + if (!str)
67 + return [];
68 +
69 + // I don't know why Bash 4.3 does this, but it does.
70 + // Anything starting with {} will have the first two bytes preserved
71 + // but *only* at the top level, so {},a}b will not expand to anything,
72 + // but a{},b}c will be expanded to [a}c,abc].
73 + // One could argue that this is a bug in Bash, but since the goal of
74 + // this module is to match Bash's rules, we escape a leading {}
75 + if (str.substr(0, 2) === '{}') {
76 + str = '\\{\\}' + str.substr(2);
77 + }
78 +
79 + return expand(escapeBraces(str), true).map(unescapeBraces);
80 +}
81 +
82 +function identity(e) {
83 + return e;
84 +}
85 +
86 +function embrace(str) {
87 + return '{' + str + '}';
88 +}
89 +function isPadded(el) {
90 + return /^-?0\d/.test(el);
91 +}
92 +
93 +function lte(i, y) {
94 + return i <= y;
95 +}
96 +function gte(i, y) {
97 + return i >= y;
98 +}
99 +
100 +function expand(str, isTop) {
101 + var expansions = [];
102 +
103 + var m = balanced('{', '}', str);
104 + if (!m || /\$$/.test(m.pre)) return [str];
105 +
106 + var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
107 + var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
108 + var isSequence = isNumericSequence || isAlphaSequence;
109 + var isOptions = m.body.indexOf(',') >= 0;
110 + if (!isSequence && !isOptions) {
111 + // {a},b}
112 + if (m.post.match(/,.*\}/)) {
113 + str = m.pre + '{' + m.body + escClose + m.post;
114 + return expand(str);
115 + }
116 + return [str];
117 + }
118 +
119 + var n;
120 + if (isSequence) {
121 + n = m.body.split(/\.\./);
122 + } else {
123 + n = parseCommaParts(m.body);
124 + if (n.length === 1) {
125 + // x{{a,b}}y ==> x{a}y x{b}y
126 + n = expand(n[0], false).map(embrace);
127 + if (n.length === 1) {
128 + var post = m.post.length
129 + ? expand(m.post, false)
130 + : [''];
131 + return post.map(function(p) {
132 + return m.pre + n[0] + p;
133 + });
134 + }
135 + }
136 + }
137 +
138 + // at this point, n is the parts, and we know it's not a comma set
139 + // with a single entry.
140 +
141 + // no need to expand pre, since it is guaranteed to be free of brace-sets
142 + var pre = m.pre;
143 + var post = m.post.length
144 + ? expand(m.post, false)
145 + : [''];
146 +
147 + var N;
148 +
149 + if (isSequence) {
150 + var x = numeric(n[0]);
151 + var y = numeric(n[1]);
152 + var width = Math.max(n[0].length, n[1].length)
153 + var incr = n.length == 3
154 + ? Math.abs(numeric(n[2]))
155 + : 1;
156 + var test = lte;
157 + var reverse = y < x;
158 + if (reverse) {
159 + incr *= -1;
160 + test = gte;
161 + }
162 + var pad = n.some(isPadded);
163 +
164 + N = [];
165 +
166 + for (var i = x; test(i, y); i += incr) {
167 + var c;
168 + if (isAlphaSequence) {
169 + c = String.fromCharCode(i);
170 + if (c === '\\')
171 + c = '';
172 + } else {
173 + c = String(i);
174 + if (pad) {
175 + var need = width - c.length;
176 + if (need > 0) {
177 + var z = new Array(need + 1).join('0');
178 + if (i < 0)
179 + c = '-' + z + c.slice(1);
180 + else
181 + c = z + c;
182 + }
183 + }
184 + }
185 + N.push(c);
186 + }
187 + } else {
188 + N = concatMap(n, function(el) { return expand(el, false) });
189 + }
190 +
191 + for (var j = 0; j < N.length; j++) {
192 + for (var k = 0; k < post.length; k++) {
193 + var expansion = pre + N[j] + post[k];
194 + if (!isTop || isSequence || expansion)
195 + expansions.push(expansion);
196 + }
197 + }
198 +
199 + return expansions;
200 +}
201 +
1 +{
2 + "name": "brace-expansion",
3 + "description": "Brace expansion as known from sh/bash",
4 + "version": "1.1.11",
5 + "repository": {
6 + "type": "git",
7 + "url": "git://github.com/juliangruber/brace-expansion.git"
8 + },
9 + "homepage": "https://github.com/juliangruber/brace-expansion",
10 + "main": "index.js",
11 + "scripts": {
12 + "test": "tape test/*.js",
13 + "gentest": "bash test/generate.sh",
14 + "bench": "matcha test/perf/bench.js"
15 + },
16 + "dependencies": {
17 + "balanced-match": "^1.0.0",
18 + "concat-map": "0.0.1"
19 + },
20 + "devDependencies": {
21 + "matcha": "^0.7.0",
22 + "tape": "^4.6.0"
23 + },
24 + "keywords": [],
25 + "author": {
26 + "name": "Julian Gruber",
27 + "email": "mail@juliangruber.com",
28 + "url": "http://juliangruber.com"
29 + },
30 + "license": "MIT",
31 + "testling": {
32 + "files": "test/*.js",
33 + "browsers": [
34 + "ie/8..latest",
35 + "firefox/20..latest",
36 + "firefox/nightly",
37 + "chrome/25..latest",
38 + "chrome/canary",
39 + "opera/12..latest",
40 + "opera/next",
41 + "safari/5.1..latest",
42 + "ipad/6.0..latest",
43 + "iphone/6.0..latest",
44 + "android-browser/4.2..latest"
45 + ]
46 + }
47 +}
1 +'use strict';
2 +const escapeStringRegexp = require('escape-string-regexp');
3 +const ansiStyles = require('ansi-styles');
4 +const stdoutColor = require('supports-color').stdout;
5 +
6 +const template = require('./templates.js');
7 +
8 +const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm');
9 +
10 +// `supportsColor.level` → `ansiStyles.color[name]` mapping
11 +const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'];
12 +
13 +// `color-convert` models to exclude from the Chalk API due to conflicts and such
14 +const skipModels = new Set(['gray']);
15 +
16 +const styles = Object.create(null);
17 +
18 +function applyOptions(obj, options) {
19 + options = options || {};
20 +
21 + // Detect level if not set manually
22 + const scLevel = stdoutColor ? stdoutColor.level : 0;
23 + obj.level = options.level === undefined ? scLevel : options.level;
24 + obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
25 +}
26 +
27 +function Chalk(options) {
28 + // We check for this.template here since calling `chalk.constructor()`
29 + // by itself will have a `this` of a previously constructed chalk object
30 + if (!this || !(this instanceof Chalk) || this.template) {
31 + const chalk = {};
32 + applyOptions(chalk, options);
33 +
34 + chalk.template = function () {
35 + const args = [].slice.call(arguments);
36 + return chalkTag.apply(null, [chalk.template].concat(args));
37 + };
38 +
39 + Object.setPrototypeOf(chalk, Chalk.prototype);
40 + Object.setPrototypeOf(chalk.template, chalk);
41 +
42 + chalk.template.constructor = Chalk;
43 +
44 + return chalk.template;
45 + }
46 +
47 + applyOptions(this, options);
48 +}
49 +
50 +// Use bright blue on Windows as the normal blue color is illegible
51 +if (isSimpleWindowsTerm) {
52 + ansiStyles.blue.open = '\u001B[94m';
53 +}
54 +
55 +for (const key of Object.keys(ansiStyles)) {
56 + ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
57 +
58 + styles[key] = {
59 + get() {
60 + const codes = ansiStyles[key];
61 + return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
62 + }
63 + };
64 +}
65 +
66 +styles.visible = {
67 + get() {
68 + return build.call(this, this._styles || [], true, 'visible');
69 + }
70 +};
71 +
72 +ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
73 +for (const model of Object.keys(ansiStyles.color.ansi)) {
74 + if (skipModels.has(model)) {
75 + continue;
76 + }
77 +
78 + styles[model] = {
79 + get() {
80 + const level = this.level;
81 + return function () {
82 + const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
83 + const codes = {
84 + open,
85 + close: ansiStyles.color.close,
86 + closeRe: ansiStyles.color.closeRe
87 + };
88 + return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
89 + };
90 + }
91 + };
92 +}
93 +
94 +ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
95 +for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
96 + if (skipModels.has(model)) {
97 + continue;
98 + }
99 +
100 + const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
101 + styles[bgModel] = {
102 + get() {
103 + const level = this.level;
104 + return function () {
105 + const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
106 + const codes = {
107 + open,
108 + close: ansiStyles.bgColor.close,
109 + closeRe: ansiStyles.bgColor.closeRe
110 + };
111 + return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
112 + };
113 + }
114 + };
115 +}
116 +
117 +const proto = Object.defineProperties(() => {}, styles);
118 +
119 +function build(_styles, _empty, key) {
120 + const builder = function () {
121 + return applyStyle.apply(builder, arguments);
122 + };
123 +
124 + builder._styles = _styles;
125 + builder._empty = _empty;
126 +
127 + const self = this;
128 +
129 + Object.defineProperty(builder, 'level', {
130 + enumerable: true,
131 + get() {
132 + return self.level;
133 + },
134 + set(level) {
135 + self.level = level;
136 + }
137 + });
138 +
139 + Object.defineProperty(builder, 'enabled', {
140 + enumerable: true,
141 + get() {
142 + return self.enabled;
143 + },
144 + set(enabled) {
145 + self.enabled = enabled;
146 + }
147 + });
148 +
149 + // See below for fix regarding invisible grey/dim combination on Windows
150 + builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey';
151 +
152 + // `__proto__` is used because we must return a function, but there is
153 + // no way to create a function with a different prototype
154 + builder.__proto__ = proto; // eslint-disable-line no-proto
155 +
156 + return builder;
157 +}
158 +
159 +function applyStyle() {
160 + // Support varags, but simply cast to string in case there's only one arg
161 + const args = arguments;
162 + const argsLen = args.length;
163 + let str = String(arguments[0]);
164 +
165 + if (argsLen === 0) {
166 + return '';
167 + }
168 +
169 + if (argsLen > 1) {
170 + // Don't slice `arguments`, it prevents V8 optimizations
171 + for (let a = 1; a < argsLen; a++) {
172 + str += ' ' + args[a];
173 + }
174 + }
175 +
176 + if (!this.enabled || this.level <= 0 || !str) {
177 + return this._empty ? '' : str;
178 + }
179 +
180 + // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
181 + // see https://github.com/chalk/chalk/issues/58
182 + // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
183 + const originalDim = ansiStyles.dim.open;
184 + if (isSimpleWindowsTerm && this.hasGrey) {
185 + ansiStyles.dim.open = '';
186 + }
187 +
188 + for (const code of this._styles.slice().reverse()) {
189 + // Replace any instances already present with a re-opening code
190 + // otherwise only the part of the string until said closing code
191 + // will be colored, and the rest will simply be 'plain'.
192 + str = code.open + str.replace(code.closeRe, code.open) + code.close;
193 +
194 + // Close the styling before a linebreak and reopen
195 + // after next line to fix a bleed issue on macOS
196 + // https://github.com/chalk/chalk/pull/92
197 + str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
198 + }
199 +
200 + // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
201 + ansiStyles.dim.open = originalDim;
202 +
203 + return str;
204 +}
205 +
206 +function chalkTag(chalk, strings) {
207 + if (!Array.isArray(strings)) {
208 + // If chalk() was called by itself or with a string,
209 + // return the string itself as a string.
210 + return [].slice.call(arguments, 1).join(' ');
211 + }
212 +
213 + const args = [].slice.call(arguments, 2);
214 + const parts = [strings.raw[0]];
215 +
216 + for (let i = 1; i < strings.length; i++) {
217 + parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
218 + parts.push(String(strings.raw[i]));
219 + }
220 +
221 + return template(chalk, parts.join(''));
222 +}
223 +
224 +Object.defineProperties(Chalk.prototype, styles);
225 +
226 +module.exports = Chalk(); // eslint-disable-line new-cap
227 +module.exports.supportsColor = stdoutColor;
228 +module.exports.default = module.exports; // For TypeScript
1 +// @flow strict
2 +
3 +type TemplateStringsArray = $ReadOnlyArray<string>;
4 +
5 +export type Level = $Values<{
6 + None: 0,
7 + Basic: 1,
8 + Ansi256: 2,
9 + TrueColor: 3
10 +}>;
11 +
12 +export type ChalkOptions = {|
13 + enabled?: boolean,
14 + level?: Level
15 +|};
16 +
17 +export type ColorSupport = {|
18 + level: Level,
19 + hasBasic: boolean,
20 + has256: boolean,
21 + has16m: boolean
22 +|};
23 +
24 +export interface Chalk {
25 + (...text: string[]): string,
26 + (text: TemplateStringsArray, ...placeholders: string[]): string,
27 + constructor(options?: ChalkOptions): Chalk,
28 + enabled: boolean,
29 + level: Level,
30 + rgb(r: number, g: number, b: number): Chalk,
31 + hsl(h: number, s: number, l: number): Chalk,
32 + hsv(h: number, s: number, v: number): Chalk,
33 + hwb(h: number, w: number, b: number): Chalk,
34 + bgHex(color: string): Chalk,
35 + bgKeyword(color: string): Chalk,
36 + bgRgb(r: number, g: number, b: number): Chalk,
37 + bgHsl(h: number, s: number, l: number): Chalk,
38 + bgHsv(h: number, s: number, v: number): Chalk,
39 + bgHwb(h: number, w: number, b: number): Chalk,
40 + hex(color: string): Chalk,
41 + keyword(color: string): Chalk,
42 +
43 + +reset: Chalk,
44 + +bold: Chalk,
45 + +dim: Chalk,
46 + +italic: Chalk,
47 + +underline: Chalk,
48 + +inverse: Chalk,
49 + +hidden: Chalk,
50 + +strikethrough: Chalk,
51 +
52 + +visible: Chalk,
53 +
54 + +black: Chalk,
55 + +red: Chalk,
56 + +green: Chalk,
57 + +yellow: Chalk,
58 + +blue: Chalk,
59 + +magenta: Chalk,
60 + +cyan: Chalk,
61 + +white: Chalk,
62 + +gray: Chalk,
63 + +grey: Chalk,
64 + +blackBright: Chalk,
65 + +redBright: Chalk,
66 + +greenBright: Chalk,
67 + +yellowBright: Chalk,
68 + +blueBright: Chalk,
69 + +magentaBright: Chalk,
70 + +cyanBright: Chalk,
71 + +whiteBright: Chalk,
72 +
73 + +bgBlack: Chalk,
74 + +bgRed: Chalk,
75 + +bgGreen: Chalk,
76 + +bgYellow: Chalk,
77 + +bgBlue: Chalk,
78 + +bgMagenta: Chalk,
79 + +bgCyan: Chalk,
80 + +bgWhite: Chalk,
81 + +bgBlackBright: Chalk,
82 + +bgRedBright: Chalk,
83 + +bgGreenBright: Chalk,
84 + +bgYellowBright: Chalk,
85 + +bgBlueBright: Chalk,
86 + +bgMagentaBright: Chalk,
87 + +bgCyanBright: Chalk,
88 + +bgWhiteBrigh: Chalk,
89 +
90 + supportsColor: ColorSupport
91 +};
92 +
93 +declare module.exports: Chalk;
1 +MIT License
2 +
3 +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4 +
5 +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:
6 +
7 +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 +
9 +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.
1 +{
2 + "name": "chalk",
3 + "version": "2.4.2",
4 + "description": "Terminal string styling done right",
5 + "license": "MIT",
6 + "repository": "chalk/chalk",
7 + "engines": {
8 + "node": ">=4"
9 + },
10 + "scripts": {
11 + "test": "xo && tsc --project types && flow --max-warnings=0 && nyc ava",
12 + "bench": "matcha benchmark.js",
13 + "coveralls": "nyc report --reporter=text-lcov | coveralls"
14 + },
15 + "files": [
16 + "index.js",
17 + "templates.js",
18 + "types/index.d.ts",
19 + "index.js.flow"
20 + ],
21 + "keywords": [
22 + "color",
23 + "colour",
24 + "colors",
25 + "terminal",
26 + "console",
27 + "cli",
28 + "string",
29 + "str",
30 + "ansi",
31 + "style",
32 + "styles",
33 + "tty",
34 + "formatting",
35 + "rgb",
36 + "256",
37 + "shell",
38 + "xterm",
39 + "log",
40 + "logging",
41 + "command-line",
42 + "text"
43 + ],
44 + "dependencies": {
45 + "ansi-styles": "^3.2.1",
46 + "escape-string-regexp": "^1.0.5",
47 + "supports-color": "^5.3.0"
48 + },
49 + "devDependencies": {
50 + "ava": "*",
51 + "coveralls": "^3.0.0",
52 + "execa": "^0.9.0",
53 + "flow-bin": "^0.68.0",
54 + "import-fresh": "^2.0.0",
55 + "matcha": "^0.7.0",
56 + "nyc": "^11.0.2",
57 + "resolve-from": "^4.0.0",
58 + "typescript": "^2.5.3",
59 + "xo": "*"
60 + },
61 + "types": "types/index.d.ts",
62 + "xo": {
63 + "envs": [
64 + "node",
65 + "mocha"
66 + ],
67 + "ignores": [
68 + "test/_flow.js"
69 + ]
70 + }
71 +}
This diff is collapsed. Click to expand it.
1 +'use strict';
2 +const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
3 +const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
4 +const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
5 +const ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
6 +
7 +const ESCAPES = new Map([
8 + ['n', '\n'],
9 + ['r', '\r'],
10 + ['t', '\t'],
11 + ['b', '\b'],
12 + ['f', '\f'],
13 + ['v', '\v'],
14 + ['0', '\0'],
15 + ['\\', '\\'],
16 + ['e', '\u001B'],
17 + ['a', '\u0007']
18 +]);
19 +
20 +function unescape(c) {
21 + if ((c[0] === 'u' && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
22 + return String.fromCharCode(parseInt(c.slice(1), 16));
23 + }
24 +
25 + return ESCAPES.get(c) || c;
26 +}
27 +
28 +function parseArguments(name, args) {
29 + const results = [];
30 + const chunks = args.trim().split(/\s*,\s*/g);
31 + let matches;
32 +
33 + for (const chunk of chunks) {
34 + if (!isNaN(chunk)) {
35 + results.push(Number(chunk));
36 + } else if ((matches = chunk.match(STRING_REGEX))) {
37 + results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr));
38 + } else {
39 + throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
40 + }
41 + }
42 +
43 + return results;
44 +}
45 +
46 +function parseStyle(style) {
47 + STYLE_REGEX.lastIndex = 0;
48 +
49 + const results = [];
50 + let matches;
51 +
52 + while ((matches = STYLE_REGEX.exec(style)) !== null) {
53 + const name = matches[1];
54 +
55 + if (matches[2]) {
56 + const args = parseArguments(name, matches[2]);
57 + results.push([name].concat(args));
58 + } else {
59 + results.push([name]);
60 + }
61 + }
62 +
63 + return results;
64 +}
65 +
66 +function buildStyle(chalk, styles) {
67 + const enabled = {};
68 +
69 + for (const layer of styles) {
70 + for (const style of layer.styles) {
71 + enabled[style[0]] = layer.inverse ? null : style.slice(1);
72 + }
73 + }
74 +
75 + let current = chalk;
76 + for (const styleName of Object.keys(enabled)) {
77 + if (Array.isArray(enabled[styleName])) {
78 + if (!(styleName in current)) {
79 + throw new Error(`Unknown Chalk style: ${styleName}`);
80 + }
81 +
82 + if (enabled[styleName].length > 0) {
83 + current = current[styleName].apply(current, enabled[styleName]);
84 + } else {
85 + current = current[styleName];
86 + }
87 + }
88 + }
89 +
90 + return current;
91 +}
92 +
93 +module.exports = (chalk, tmp) => {
94 + const styles = [];
95 + const chunks = [];
96 + let chunk = [];
97 +
98 + // eslint-disable-next-line max-params
99 + tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => {
100 + if (escapeChar) {
101 + chunk.push(unescape(escapeChar));
102 + } else if (style) {
103 + const str = chunk.join('');
104 + chunk = [];
105 + chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
106 + styles.push({inverse, styles: parseStyle(style)});
107 + } else if (close) {
108 + if (styles.length === 0) {
109 + throw new Error('Found extraneous } in Chalk template literal');
110 + }
111 +
112 + chunks.push(buildStyle(chalk, styles)(chunk.join('')));
113 + chunk = [];
114 + styles.pop();
115 + } else {
116 + chunk.push(chr);
117 + }
118 + });
119 +
120 + chunks.push(chunk.join(''));
121 +
122 + if (styles.length > 0) {
123 + const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
124 + throw new Error(errMsg);
125 + }
126 +
127 + return chunks.join('');
128 +};
1 +// Type definitions for Chalk
2 +// Definitions by: Thomas Sauer <https://github.com/t-sauer>
3 +
4 +export const enum Level {
5 + None = 0,
6 + Basic = 1,
7 + Ansi256 = 2,
8 + TrueColor = 3
9 +}
10 +
11 +export interface ChalkOptions {
12 + enabled?: boolean;
13 + level?: Level;
14 +}
15 +
16 +export interface ChalkConstructor {
17 + new (options?: ChalkOptions): Chalk;
18 + (options?: ChalkOptions): Chalk;
19 +}
20 +
21 +export interface ColorSupport {
22 + level: Level;
23 + hasBasic: boolean;
24 + has256: boolean;
25 + has16m: boolean;
26 +}
27 +
28 +export interface Chalk {
29 + (...text: string[]): string;
30 + (text: TemplateStringsArray, ...placeholders: string[]): string;
31 + constructor: ChalkConstructor;
32 + enabled: boolean;
33 + level: Level;
34 + rgb(r: number, g: number, b: number): this;
35 + hsl(h: number, s: number, l: number): this;
36 + hsv(h: number, s: number, v: number): this;
37 + hwb(h: number, w: number, b: number): this;
38 + bgHex(color: string): this;
39 + bgKeyword(color: string): this;
40 + bgRgb(r: number, g: number, b: number): this;
41 + bgHsl(h: number, s: number, l: number): this;
42 + bgHsv(h: number, s: number, v: number): this;
43 + bgHwb(h: number, w: number, b: number): this;
44 + hex(color: string): this;
45 + keyword(color: string): this;
46 +
47 + readonly reset: this;
48 + readonly bold: this;
49 + readonly dim: this;
50 + readonly italic: this;
51 + readonly underline: this;
52 + readonly inverse: this;
53 + readonly hidden: this;
54 + readonly strikethrough: this;
55 +
56 + readonly visible: this;
57 +
58 + readonly black: this;
59 + readonly red: this;
60 + readonly green: this;
61 + readonly yellow: this;
62 + readonly blue: this;
63 + readonly magenta: this;
64 + readonly cyan: this;
65 + readonly white: this;
66 + readonly gray: this;
67 + readonly grey: this;
68 + readonly blackBright: this;
69 + readonly redBright: this;
70 + readonly greenBright: this;
71 + readonly yellowBright: this;
72 + readonly blueBright: this;
73 + readonly magentaBright: this;
74 + readonly cyanBright: this;
75 + readonly whiteBright: this;
76 +
77 + readonly bgBlack: this;
78 + readonly bgRed: this;
79 + readonly bgGreen: this;
80 + readonly bgYellow: this;
81 + readonly bgBlue: this;
82 + readonly bgMagenta: this;
83 + readonly bgCyan: this;
84 + readonly bgWhite: this;
85 + readonly bgBlackBright: this;
86 + readonly bgRedBright: this;
87 + readonly bgGreenBright: this;
88 + readonly bgYellowBright: this;
89 + readonly bgBlueBright: this;
90 + readonly bgMagentaBright: this;
91 + readonly bgCyanBright: this;
92 + readonly bgWhiteBright: this;
93 +}
94 +
95 +declare const chalk: Chalk & { supportsColor: ColorSupport };
96 +
97 +export default chalk
1 +# 1.0.0 - 2016-01-07
2 +
3 +- Removed: unused speed test
4 +- Added: Automatic routing between previously unsupported conversions
5 +([#27](https://github.com/Qix-/color-convert/pull/27))
6 +- Removed: `xxx2xxx()` and `xxx2xxxRaw()` functions
7 +([#27](https://github.com/Qix-/color-convert/pull/27))
8 +- Removed: `convert()` class
9 +([#27](https://github.com/Qix-/color-convert/pull/27))
10 +- Changed: all functions to lookup dictionary
11 +([#27](https://github.com/Qix-/color-convert/pull/27))
12 +- Changed: `ansi` to `ansi256`
13 +([#27](https://github.com/Qix-/color-convert/pull/27))
14 +- Fixed: argument grouping for functions requiring only one argument
15 +([#27](https://github.com/Qix-/color-convert/pull/27))
16 +
17 +# 0.6.0 - 2015-07-23
18 +
19 +- Added: methods to handle
20 +[ANSI](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors) 16/256 colors:
21 + - rgb2ansi16
22 + - rgb2ansi
23 + - hsl2ansi16
24 + - hsl2ansi
25 + - hsv2ansi16
26 + - hsv2ansi
27 + - hwb2ansi16
28 + - hwb2ansi
29 + - cmyk2ansi16
30 + - cmyk2ansi
31 + - keyword2ansi16
32 + - keyword2ansi
33 + - ansi162rgb
34 + - ansi162hsl
35 + - ansi162hsv
36 + - ansi162hwb
37 + - ansi162cmyk
38 + - ansi162keyword
39 + - ansi2rgb
40 + - ansi2hsl
41 + - ansi2hsv
42 + - ansi2hwb
43 + - ansi2cmyk
44 + - ansi2keyword
45 +([#18](https://github.com/harthur/color-convert/pull/18))
46 +
47 +# 0.5.3 - 2015-06-02
48 +
49 +- Fixed: hsl2hsv does not return `NaN` anymore when using `[0,0,0]`
50 +([#15](https://github.com/harthur/color-convert/issues/15))
51 +
52 +---
53 +
54 +Check out commit logs for older releases
1 +Copyright (c) 2011-2016 Heather Arthur <fayearthur@gmail.com>
2 +
3 +Permission is hereby granted, free of charge, to any person obtaining
4 +a copy of this software and associated documentation files (the
5 +"Software"), to deal in the Software without restriction, including
6 +without limitation the rights to use, copy, modify, merge, publish,
7 +distribute, sublicense, and/or sell copies of the Software, and to
8 +permit persons to whom the Software is furnished to do so, subject to
9 +the following conditions:
10 +
11 +The above copyright notice and this permission notice shall be
12 +included in all copies or substantial portions of the Software.
13 +
14 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 +
1 +# color-convert
2 +
3 +[![Build Status](https://travis-ci.org/Qix-/color-convert.svg?branch=master)](https://travis-ci.org/Qix-/color-convert)
4 +
5 +Color-convert is a color conversion library for JavaScript and node.
6 +It converts all ways between `rgb`, `hsl`, `hsv`, `hwb`, `cmyk`, `ansi`, `ansi16`, `hex` strings, and CSS `keyword`s (will round to closest):
7 +
8 +```js
9 +var convert = require('color-convert');
10 +
11 +convert.rgb.hsl(140, 200, 100); // [96, 48, 59]
12 +convert.keyword.rgb('blue'); // [0, 0, 255]
13 +
14 +var rgbChannels = convert.rgb.channels; // 3
15 +var cmykChannels = convert.cmyk.channels; // 4
16 +var ansiChannels = convert.ansi16.channels; // 1
17 +```
18 +
19 +# Install
20 +
21 +```console
22 +$ npm install color-convert
23 +```
24 +
25 +# API
26 +
27 +Simply get the property of the _from_ and _to_ conversion that you're looking for.
28 +
29 +All functions have a rounded and unrounded variant. By default, return values are rounded. To get the unrounded (raw) results, simply tack on `.raw` to the function.
30 +
31 +All 'from' functions have a hidden property called `.channels` that indicates the number of channels the function expects (not including alpha).
32 +
33 +```js
34 +var convert = require('color-convert');
35 +
36 +// Hex to LAB
37 +convert.hex.lab('DEADBF'); // [ 76, 21, -2 ]
38 +convert.hex.lab.raw('DEADBF'); // [ 75.56213190997677, 20.653827952644754, -2.290532499330533 ]
39 +
40 +// RGB to CMYK
41 +convert.rgb.cmyk(167, 255, 4); // [ 35, 0, 98, 0 ]
42 +convert.rgb.cmyk.raw(167, 255, 4); // [ 34.509803921568626, 0, 98.43137254901961, 0 ]
43 +```
44 +
45 +### Arrays
46 +All functions that accept multiple arguments also support passing an array.
47 +
48 +Note that this does **not** apply to functions that convert from a color that only requires one value (e.g. `keyword`, `ansi256`, `hex`, etc.)
49 +
50 +```js
51 +var convert = require('color-convert');
52 +
53 +convert.rgb.hex(123, 45, 67); // '7B2D43'
54 +convert.rgb.hex([123, 45, 67]); // '7B2D43'
55 +```
56 +
57 +## Routing
58 +
59 +Conversions that don't have an _explicitly_ defined conversion (in [conversions.js](conversions.js)), but can be converted by means of sub-conversions (e.g. XYZ -> **RGB** -> CMYK), are automatically routed together. This allows just about any color model supported by `color-convert` to be converted to any other model, so long as a sub-conversion path exists. This is also true for conversions requiring more than one step in between (e.g. LCH -> **LAB** -> **XYZ** -> **RGB** -> Hex).
60 +
61 +Keep in mind that extensive conversions _may_ result in a loss of precision, and exist only to be complete. For a list of "direct" (single-step) conversions, see [conversions.js](conversions.js).
62 +
63 +# Contribute
64 +
65 +If there is a new model you would like to support, or want to add a direct conversion between two existing models, please send us a pull request.
66 +
67 +# License
68 +Copyright &copy; 2011-2016, Heather Arthur and Josh Junon. Licensed under the [MIT License](LICENSE).
This diff is collapsed. Click to expand it.
1 +var conversions = require('./conversions');
2 +var route = require('./route');
3 +
4 +var convert = {};
5 +
6 +var models = Object.keys(conversions);
7 +
8 +function wrapRaw(fn) {
9 + var wrappedFn = function (args) {
10 + if (args === undefined || args === null) {
11 + return args;
12 + }
13 +
14 + if (arguments.length > 1) {
15 + args = Array.prototype.slice.call(arguments);
16 + }
17 +
18 + return fn(args);
19 + };
20 +
21 + // preserve .conversion property if there is one
22 + if ('conversion' in fn) {
23 + wrappedFn.conversion = fn.conversion;
24 + }
25 +
26 + return wrappedFn;
27 +}
28 +
29 +function wrapRounded(fn) {
30 + var wrappedFn = function (args) {
31 + if (args === undefined || args === null) {
32 + return args;
33 + }
34 +
35 + if (arguments.length > 1) {
36 + args = Array.prototype.slice.call(arguments);
37 + }
38 +
39 + var result = fn(args);
40 +
41 + // we're assuming the result is an array here.
42 + // see notice in conversions.js; don't use box types
43 + // in conversion functions.
44 + if (typeof result === 'object') {
45 + for (var len = result.length, i = 0; i < len; i++) {
46 + result[i] = Math.round(result[i]);
47 + }
48 + }
49 +
50 + return result;
51 + };
52 +
53 + // preserve .conversion property if there is one
54 + if ('conversion' in fn) {
55 + wrappedFn.conversion = fn.conversion;
56 + }
57 +
58 + return wrappedFn;
59 +}
60 +
61 +models.forEach(function (fromModel) {
62 + convert[fromModel] = {};
63 +
64 + Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
65 + Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
66 +
67 + var routes = route(fromModel);
68 + var routeModels = Object.keys(routes);
69 +
70 + routeModels.forEach(function (toModel) {
71 + var fn = routes[toModel];
72 +
73 + convert[fromModel][toModel] = wrapRounded(fn);
74 + convert[fromModel][toModel].raw = wrapRaw(fn);
75 + });
76 +});
77 +
78 +module.exports = convert;
1 +{
2 + "name": "color-convert",
3 + "description": "Plain color conversion functions",
4 + "version": "1.9.3",
5 + "author": "Heather Arthur <fayearthur@gmail.com>",
6 + "license": "MIT",
7 + "repository": "Qix-/color-convert",
8 + "scripts": {
9 + "pretest": "xo",
10 + "test": "node test/basic.js"
11 + },
12 + "keywords": [
13 + "color",
14 + "colour",
15 + "convert",
16 + "converter",
17 + "conversion",
18 + "rgb",
19 + "hsl",
20 + "hsv",
21 + "hwb",
22 + "cmyk",
23 + "ansi",
24 + "ansi16"
25 + ],
26 + "files": [
27 + "index.js",
28 + "conversions.js",
29 + "css-keywords.js",
30 + "route.js"
31 + ],
32 + "xo": {
33 + "rules": {
34 + "default-case": 0,
35 + "no-inline-comments": 0,
36 + "operator-linebreak": 0
37 + }
38 + },
39 + "devDependencies": {
40 + "chalk": "1.1.1",
41 + "xo": "0.11.2"
42 + },
43 + "dependencies": {
44 + "color-name": "1.1.3"
45 + }
46 +}
1 +var conversions = require('./conversions');
2 +
3 +/*
4 + this function routes a model to all other models.
5 +
6 + all functions that are routed have a property `.conversion` attached
7 + to the returned synthetic function. This property is an array
8 + of strings, each with the steps in between the 'from' and 'to'
9 + color models (inclusive).
10 +
11 + conversions that are not possible simply are not included.
12 +*/
13 +
14 +function buildGraph() {
15 + var graph = {};
16 + // https://jsperf.com/object-keys-vs-for-in-with-closure/3
17 + var models = Object.keys(conversions);
18 +
19 + for (var len = models.length, i = 0; i < len; i++) {
20 + graph[models[i]] = {
21 + // http://jsperf.com/1-vs-infinity
22 + // micro-opt, but this is simple.
23 + distance: -1,
24 + parent: null
25 + };
26 + }
27 +
28 + return graph;
29 +}
30 +
31 +// https://en.wikipedia.org/wiki/Breadth-first_search
32 +function deriveBFS(fromModel) {
33 + var graph = buildGraph();
34 + var queue = [fromModel]; // unshift -> queue -> pop
35 +
36 + graph[fromModel].distance = 0;
37 +
38 + while (queue.length) {
39 + var current = queue.pop();
40 + var adjacents = Object.keys(conversions[current]);
41 +
42 + for (var len = adjacents.length, i = 0; i < len; i++) {
43 + var adjacent = adjacents[i];
44 + var node = graph[adjacent];
45 +
46 + if (node.distance === -1) {
47 + node.distance = graph[current].distance + 1;
48 + node.parent = current;
49 + queue.unshift(adjacent);
50 + }
51 + }
52 + }
53 +
54 + return graph;
55 +}
56 +
57 +function link(from, to) {
58 + return function (args) {
59 + return to(from(args));
60 + };
61 +}
62 +
63 +function wrapConversion(toModel, graph) {
64 + var path = [graph[toModel].parent, toModel];
65 + var fn = conversions[graph[toModel].parent][toModel];
66 +
67 + var cur = graph[toModel].parent;
68 + while (graph[cur].parent) {
69 + path.unshift(graph[cur].parent);
70 + fn = link(conversions[graph[cur].parent][cur], fn);
71 + cur = graph[cur].parent;
72 + }
73 +
74 + fn.conversion = path;
75 + return fn;
76 +}
77 +
78 +module.exports = function (fromModel) {
79 + var graph = deriveBFS(fromModel);
80 + var conversion = {};
81 +
82 + var models = Object.keys(graph);
83 + for (var len = models.length, i = 0; i < len; i++) {
84 + var toModel = models[i];
85 + var node = graph[toModel];
86 +
87 + if (node.parent === null) {
88 + // no possible conversion, or this node is the source model.
89 + continue;
90 + }
91 +
92 + conversion[toModel] = wrapConversion(toModel, graph);
93 + }
94 +
95 + return conversion;
96 +};
97 +
1 +{
2 + "env": {
3 + "browser": true,
4 + "node": true,
5 + "commonjs": true,
6 + "es6": true
7 + },
8 + "extends": "eslint:recommended",
9 + "rules": {
10 + "strict": 2,
11 + "indent": 0,
12 + "linebreak-style": 0,
13 + "quotes": 0,
14 + "semi": 0,
15 + "no-cond-assign": 1,
16 + "no-constant-condition": 1,
17 + "no-duplicate-case": 1,
18 + "no-empty": 1,
19 + "no-ex-assign": 1,
20 + "no-extra-boolean-cast": 1,
21 + "no-extra-semi": 1,
22 + "no-fallthrough": 1,
23 + "no-func-assign": 1,
24 + "no-global-assign": 1,
25 + "no-implicit-globals": 2,
26 + "no-inner-declarations": ["error", "functions"],
27 + "no-irregular-whitespace": 2,
28 + "no-loop-func": 1,
29 + "no-multi-str": 1,
30 + "no-mixed-spaces-and-tabs": 1,
31 + "no-proto": 1,
32 + "no-sequences": 1,
33 + "no-throw-literal": 1,
34 + "no-unmodified-loop-condition": 1,
35 + "no-useless-call": 1,
36 + "no-void": 1,
37 + "no-with": 2,
38 + "wrap-iife": 1,
39 + "no-redeclare": 1,
40 + "no-unused-vars": ["error", { "vars": "all", "args": "none" }],
41 + "no-sparse-arrays": 1
42 + }
43 +}
1 +//this will affect all the git repos
2 +git config --global core.excludesfile ~/.gitignore
3 +
4 +
5 +//update files since .ignore won't if already tracked
6 +git rm --cached <file>
7 +
8 +# Compiled source #
9 +###################
10 +*.com
11 +*.class
12 +*.dll
13 +*.exe
14 +*.o
15 +*.so
16 +
17 +# Packages #
18 +############
19 +# it's better to unpack these files and commit the raw source
20 +# git has its own built in compression methods
21 +*.7z
22 +*.dmg
23 +*.gz
24 +*.iso
25 +*.jar
26 +*.rar
27 +*.tar
28 +*.zip
29 +
30 +# Logs and databases #
31 +######################
32 +*.log
33 +*.sql
34 +*.sqlite
35 +
36 +# OS generated files #
37 +######################
38 +.DS_Store
39 +.DS_Store?
40 +._*
41 +.Spotlight-V100
42 +.Trashes
43 +# Icon?
44 +ehthumbs.db
45 +Thumbs.db
46 +.cache
47 +.project
48 +.settings
49 +.tmproj
50 +*.esproj
51 +nbproject
52 +
53 +# Numerous always-ignore extensions #
54 +#####################################
55 +*.diff
56 +*.err
57 +*.orig
58 +*.rej
59 +*.swn
60 +*.swo
61 +*.swp
62 +*.vi
63 +*~
64 +*.sass-cache
65 +*.grunt
66 +*.tmp
67 +
68 +# Dreamweaver added files #
69 +###########################
70 +_notes
71 +dwsync.xml
72 +
73 +# Komodo #
74 +###########################
75 +*.komodoproject
76 +.komodotools
77 +
78 +# Node #
79 +#####################
80 +node_modules
81 +
82 +# Bower #
83 +#####################
84 +bower_components
85 +
86 +# Folders to ignore #
87 +#####################
88 +.hg
89 +.svn
90 +.CVS
91 +intermediate
92 +publish
93 +.idea
94 +.graphics
95 +_test
96 +_archive
97 +uploads
98 +tmp
99 +
100 +# Vim files to ignore #
101 +#######################
102 +.VimballRecord
103 +.netrwhist
104 +
105 +bundle.*
106 +
107 +_demo
...\ No newline at end of file ...\ No newline at end of file
1 +The MIT License (MIT)
2 +Copyright (c) 2015 Dmitry Ivanov
3 +
4 +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:
5 +
6 +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 +
8 +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.
...\ No newline at end of file ...\ No newline at end of file
1 +A JSON with color names and its values. Based on http://dev.w3.org/csswg/css-color/#named-colors.
2 +
3 +[![NPM](https://nodei.co/npm/color-name.png?mini=true)](https://nodei.co/npm/color-name/)
4 +
5 +
6 +```js
7 +var colors = require('color-name');
8 +colors.red //[255,0,0]
9 +```
10 +
11 +<a href="LICENSE"><img src="https://upload.wikimedia.org/wikipedia/commons/0/0c/MIT_logo.svg" width="120"/></a>
1 +'use strict'
2 +
3 +module.exports = {
4 + "aliceblue": [240, 248, 255],
5 + "antiquewhite": [250, 235, 215],
6 + "aqua": [0, 255, 255],
7 + "aquamarine": [127, 255, 212],
8 + "azure": [240, 255, 255],
9 + "beige": [245, 245, 220],
10 + "bisque": [255, 228, 196],
11 + "black": [0, 0, 0],
12 + "blanchedalmond": [255, 235, 205],
13 + "blue": [0, 0, 255],
14 + "blueviolet": [138, 43, 226],
15 + "brown": [165, 42, 42],
16 + "burlywood": [222, 184, 135],
17 + "cadetblue": [95, 158, 160],
18 + "chartreuse": [127, 255, 0],
19 + "chocolate": [210, 105, 30],
20 + "coral": [255, 127, 80],
21 + "cornflowerblue": [100, 149, 237],
22 + "cornsilk": [255, 248, 220],
23 + "crimson": [220, 20, 60],
24 + "cyan": [0, 255, 255],
25 + "darkblue": [0, 0, 139],
26 + "darkcyan": [0, 139, 139],
27 + "darkgoldenrod": [184, 134, 11],
28 + "darkgray": [169, 169, 169],
29 + "darkgreen": [0, 100, 0],
30 + "darkgrey": [169, 169, 169],
31 + "darkkhaki": [189, 183, 107],
32 + "darkmagenta": [139, 0, 139],
33 + "darkolivegreen": [85, 107, 47],
34 + "darkorange": [255, 140, 0],
35 + "darkorchid": [153, 50, 204],
36 + "darkred": [139, 0, 0],
37 + "darksalmon": [233, 150, 122],
38 + "darkseagreen": [143, 188, 143],
39 + "darkslateblue": [72, 61, 139],
40 + "darkslategray": [47, 79, 79],
41 + "darkslategrey": [47, 79, 79],
42 + "darkturquoise": [0, 206, 209],
43 + "darkviolet": [148, 0, 211],
44 + "deeppink": [255, 20, 147],
45 + "deepskyblue": [0, 191, 255],
46 + "dimgray": [105, 105, 105],
47 + "dimgrey": [105, 105, 105],
48 + "dodgerblue": [30, 144, 255],
49 + "firebrick": [178, 34, 34],
50 + "floralwhite": [255, 250, 240],
51 + "forestgreen": [34, 139, 34],
52 + "fuchsia": [255, 0, 255],
53 + "gainsboro": [220, 220, 220],
54 + "ghostwhite": [248, 248, 255],
55 + "gold": [255, 215, 0],
56 + "goldenrod": [218, 165, 32],
57 + "gray": [128, 128, 128],
58 + "green": [0, 128, 0],
59 + "greenyellow": [173, 255, 47],
60 + "grey": [128, 128, 128],
61 + "honeydew": [240, 255, 240],
62 + "hotpink": [255, 105, 180],
63 + "indianred": [205, 92, 92],
64 + "indigo": [75, 0, 130],
65 + "ivory": [255, 255, 240],
66 + "khaki": [240, 230, 140],
67 + "lavender": [230, 230, 250],
68 + "lavenderblush": [255, 240, 245],
69 + "lawngreen": [124, 252, 0],
70 + "lemonchiffon": [255, 250, 205],
71 + "lightblue": [173, 216, 230],
72 + "lightcoral": [240, 128, 128],
73 + "lightcyan": [224, 255, 255],
74 + "lightgoldenrodyellow": [250, 250, 210],
75 + "lightgray": [211, 211, 211],
76 + "lightgreen": [144, 238, 144],
77 + "lightgrey": [211, 211, 211],
78 + "lightpink": [255, 182, 193],
79 + "lightsalmon": [255, 160, 122],
80 + "lightseagreen": [32, 178, 170],
81 + "lightskyblue": [135, 206, 250],
82 + "lightslategray": [119, 136, 153],
83 + "lightslategrey": [119, 136, 153],
84 + "lightsteelblue": [176, 196, 222],
85 + "lightyellow": [255, 255, 224],
86 + "lime": [0, 255, 0],
87 + "limegreen": [50, 205, 50],
88 + "linen": [250, 240, 230],
89 + "magenta": [255, 0, 255],
90 + "maroon": [128, 0, 0],
91 + "mediumaquamarine": [102, 205, 170],
92 + "mediumblue": [0, 0, 205],
93 + "mediumorchid": [186, 85, 211],
94 + "mediumpurple": [147, 112, 219],
95 + "mediumseagreen": [60, 179, 113],
96 + "mediumslateblue": [123, 104, 238],
97 + "mediumspringgreen": [0, 250, 154],
98 + "mediumturquoise": [72, 209, 204],
99 + "mediumvioletred": [199, 21, 133],
100 + "midnightblue": [25, 25, 112],
101 + "mintcream": [245, 255, 250],
102 + "mistyrose": [255, 228, 225],
103 + "moccasin": [255, 228, 181],
104 + "navajowhite": [255, 222, 173],
105 + "navy": [0, 0, 128],
106 + "oldlace": [253, 245, 230],
107 + "olive": [128, 128, 0],
108 + "olivedrab": [107, 142, 35],
109 + "orange": [255, 165, 0],
110 + "orangered": [255, 69, 0],
111 + "orchid": [218, 112, 214],
112 + "palegoldenrod": [238, 232, 170],
113 + "palegreen": [152, 251, 152],
114 + "paleturquoise": [175, 238, 238],
115 + "palevioletred": [219, 112, 147],
116 + "papayawhip": [255, 239, 213],
117 + "peachpuff": [255, 218, 185],
118 + "peru": [205, 133, 63],
119 + "pink": [255, 192, 203],
120 + "plum": [221, 160, 221],
121 + "powderblue": [176, 224, 230],
122 + "purple": [128, 0, 128],
123 + "rebeccapurple": [102, 51, 153],
124 + "red": [255, 0, 0],
125 + "rosybrown": [188, 143, 143],
126 + "royalblue": [65, 105, 225],
127 + "saddlebrown": [139, 69, 19],
128 + "salmon": [250, 128, 114],
129 + "sandybrown": [244, 164, 96],
130 + "seagreen": [46, 139, 87],
131 + "seashell": [255, 245, 238],
132 + "sienna": [160, 82, 45],
133 + "silver": [192, 192, 192],
134 + "skyblue": [135, 206, 235],
135 + "slateblue": [106, 90, 205],
136 + "slategray": [112, 128, 144],
137 + "slategrey": [112, 128, 144],
138 + "snow": [255, 250, 250],
139 + "springgreen": [0, 255, 127],
140 + "steelblue": [70, 130, 180],
141 + "tan": [210, 180, 140],
142 + "teal": [0, 128, 128],
143 + "thistle": [216, 191, 216],
144 + "tomato": [255, 99, 71],
145 + "turquoise": [64, 224, 208],
146 + "violet": [238, 130, 238],
147 + "wheat": [245, 222, 179],
148 + "white": [255, 255, 255],
149 + "whitesmoke": [245, 245, 245],
150 + "yellow": [255, 255, 0],
151 + "yellowgreen": [154, 205, 50]
152 +};
1 +{
2 + "name": "color-name",
3 + "version": "1.1.3",
4 + "description": "A list of color names and its values",
5 + "main": "index.js",
6 + "scripts": {
7 + "test": "node test.js"
8 + },
9 + "repository": {
10 + "type": "git",
11 + "url": "git@github.com:dfcreative/color-name.git"
12 + },
13 + "keywords": [
14 + "color-name",
15 + "color",
16 + "color-keyword",
17 + "keyword"
18 + ],
19 + "author": "DY <dfcreative@gmail.com>",
20 + "license": "MIT",
21 + "bugs": {
22 + "url": "https://github.com/dfcreative/color-name/issues"
23 + },
24 + "homepage": "https://github.com/dfcreative/color-name"
25 +}
1 +'use strict'
2 +
3 +var names = require('./');
4 +var assert = require('assert');
5 +
6 +assert.deepEqual(names.red, [255,0,0]);
7 +assert.deepEqual(names.aliceblue, [240,248,255]);
1 +language: node_js
2 +node_js:
3 + - 0.4
4 + - 0.6
1 +This software is released under the MIT license:
2 +
3 +Permission is hereby granted, free of charge, to any person obtaining a copy of
4 +this software and associated documentation files (the "Software"), to deal in
5 +the Software without restriction, including without limitation the rights to
6 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7 +the Software, and to permit persons to whom the Software is furnished to do so,
8 +subject to the following conditions:
9 +
10 +The above copyright notice and this permission notice shall be included in all
11 +copies or substantial portions of the Software.
12 +
13 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15 +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16 +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17 +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +concat-map
2 +==========
3 +
4 +Concatenative mapdashery.
5 +
6 +[![browser support](http://ci.testling.com/substack/node-concat-map.png)](http://ci.testling.com/substack/node-concat-map)
7 +
8 +[![build status](https://secure.travis-ci.org/substack/node-concat-map.png)](http://travis-ci.org/substack/node-concat-map)
9 +
10 +example
11 +=======
12 +
13 +``` js
14 +var concatMap = require('concat-map');
15 +var xs = [ 1, 2, 3, 4, 5, 6 ];
16 +var ys = concatMap(xs, function (x) {
17 + return x % 2 ? [ x - 0.1, x, x + 0.1 ] : [];
18 +});
19 +console.dir(ys);
20 +```
21 +
22 +***
23 +
24 +```
25 +[ 0.9, 1, 1.1, 2.9, 3, 3.1, 4.9, 5, 5.1 ]
26 +```
27 +
28 +methods
29 +=======
30 +
31 +``` js
32 +var concatMap = require('concat-map')
33 +```
34 +
35 +concatMap(xs, fn)
36 +-----------------
37 +
38 +Return an array of concatenated elements by calling `fn(x, i)` for each element
39 +`x` and each index `i` in the array `xs`.
40 +
41 +When `fn(x, i)` returns an array, its result will be concatenated with the
42 +result array. If `fn(x, i)` returns anything else, that value will be pushed
43 +onto the end of the result array.
44 +
45 +install
46 +=======
47 +
48 +With [npm](http://npmjs.org) do:
49 +
50 +```
51 +npm install concat-map
52 +```
53 +
54 +license
55 +=======
56 +
57 +MIT
58 +
59 +notes
60 +=====
61 +
62 +This module was written while sitting high above the ground in a tree.
1 +var concatMap = require('../');
2 +var xs = [ 1, 2, 3, 4, 5, 6 ];
3 +var ys = concatMap(xs, function (x) {
4 + return x % 2 ? [ x - 0.1, x, x + 0.1 ] : [];
5 +});
6 +console.dir(ys);
1 +module.exports = function (xs, fn) {
2 + var res = [];
3 + for (var i = 0; i < xs.length; i++) {
4 + var x = fn(xs[i], i);
5 + if (isArray(x)) res.push.apply(res, x);
6 + else res.push(x);
7 + }
8 + return res;
9 +};
10 +
11 +var isArray = Array.isArray || function (xs) {
12 + return Object.prototype.toString.call(xs) === '[object Array]';
13 +};
1 +{
2 + "name" : "concat-map",
3 + "description" : "concatenative mapdashery",
4 + "version" : "0.0.1",
5 + "repository" : {
6 + "type" : "git",
7 + "url" : "git://github.com/substack/node-concat-map.git"
8 + },
9 + "main" : "index.js",
10 + "keywords" : [
11 + "concat",
12 + "concatMap",
13 + "map",
14 + "functional",
15 + "higher-order"
16 + ],
17 + "directories" : {
18 + "example" : "example",
19 + "test" : "test"
20 + },
21 + "scripts" : {
22 + "test" : "tape test/*.js"
23 + },
24 + "devDependencies" : {
25 + "tape" : "~2.4.0"
26 + },
27 + "license" : "MIT",
28 + "author" : {
29 + "name" : "James Halliday",
30 + "email" : "mail@substack.net",
31 + "url" : "http://substack.net"
32 + },
33 + "testling" : {
34 + "files" : "test/*.js",
35 + "browsers" : {
36 + "ie" : [ 6, 7, 8, 9 ],
37 + "ff" : [ 3.5, 10, 15.0 ],
38 + "chrome" : [ 10, 22 ],
39 + "safari" : [ 5.1 ],
40 + "opera" : [ 12 ]
41 + }
42 + }
43 +}
1 +var concatMap = require('../');
2 +var test = require('tape');
3 +
4 +test('empty or not', function (t) {
5 + var xs = [ 1, 2, 3, 4, 5, 6 ];
6 + var ixes = [];
7 + var ys = concatMap(xs, function (x, ix) {
8 + ixes.push(ix);
9 + return x % 2 ? [ x - 0.1, x, x + 0.1 ] : [];
10 + });
11 + t.same(ys, [ 0.9, 1, 1.1, 2.9, 3, 3.1, 4.9, 5, 5.1 ]);
12 + t.same(ixes, [ 0, 1, 2, 3, 4, 5 ]);
13 + t.end();
14 +});
15 +
16 +test('always something', function (t) {
17 + var xs = [ 'a', 'b', 'c', 'd' ];
18 + var ys = concatMap(xs, function (x) {
19 + return x === 'b' ? [ 'B', 'B', 'B' ] : [ x ];
20 + });
21 + t.same(ys, [ 'a', 'B', 'B', 'B', 'c', 'd' ]);
22 + t.end();
23 +});
24 +
25 +test('scalars', function (t) {
26 + var xs = [ 'a', 'b', 'c', 'd' ];
27 + var ys = concatMap(xs, function (x) {
28 + return x === 'b' ? [ 'B', 'B', 'B' ] : x;
29 + });
30 + t.same(ys, [ 'a', 'B', 'B', 'B', 'c', 'd' ]);
31 + t.end();
32 +});
33 +
34 +test('undefs', function (t) {
35 + var xs = [ 'a', 'b', 'c', 'd' ];
36 + var ys = concatMap(xs, function () {});
37 + t.same(ys, [ undefined, undefined, undefined, undefined ]);
38 + t.end();
39 +});
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 +#!/usr/bin/env node
2 +/*
3 + * EJS Embedded JavaScript templates
4 + * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
5 + *
6 + * Licensed under the Apache License, Version 2.0 (the "License");
7 + * you may not use this file except in compliance with the License.
8 + * You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing, software
13 + * distributed under the License is distributed on an "AS IS" BASIS,
14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 + * See the License for the specific language governing permissions and
16 + * limitations under the License.
17 + *
18 +*/
19 +
20 +
21 +let program = require('jake').program;
22 +delete global.jake; // NO NOT WANT
23 +program.setTaskNames = function (n) { this.taskNames = n; };
24 +
25 +let ejs = require('../lib/ejs');
26 +let { hyphenToCamel } = require('../lib/utils');
27 +let fs = require('fs');
28 +let args = process.argv.slice(2);
29 +let usage = fs.readFileSync(`${__dirname}/../usage.txt`).toString();
30 +
31 +const CLI_OPTS = [
32 + { full: 'output-file',
33 + abbr: 'o',
34 + expectValue: true,
35 + },
36 + { full: 'data-file',
37 + abbr: 'f',
38 + expectValue: true,
39 + },
40 + { full: 'data-input',
41 + abbr: 'i',
42 + expectValue: true,
43 + },
44 + { full: 'delimiter',
45 + abbr: 'm',
46 + expectValue: true,
47 + passThrough: true,
48 + },
49 + { full: 'open-delimiter',
50 + abbr: 'p',
51 + expectValue: true,
52 + passThrough: true,
53 + },
54 + { full: 'close-delimiter',
55 + abbr: 'c',
56 + expectValue: true,
57 + passThrough: true,
58 + },
59 + { full: 'strict',
60 + abbr: 's',
61 + expectValue: false,
62 + allowValue: false,
63 + passThrough: true,
64 + },
65 + { full: 'no-with',
66 + abbr: 'n',
67 + expectValue: false,
68 + allowValue: false,
69 + },
70 + { full: 'locals-name',
71 + abbr: 'l',
72 + expectValue: true,
73 + passThrough: true,
74 + },
75 + { full: 'rm-whitespace',
76 + abbr: 'w',
77 + expectValue: false,
78 + allowValue: false,
79 + passThrough: true,
80 + },
81 + { full: 'debug',
82 + abbr: 'd',
83 + expectValue: false,
84 + allowValue: false,
85 + passThrough: true,
86 + },
87 + { full: 'help',
88 + abbr: 'h',
89 + passThrough: true,
90 + },
91 + { full: 'version',
92 + abbr: 'V',
93 + passThrough: true,
94 + },
95 + // Alias lowercase v
96 + { full: 'version',
97 + abbr: 'v',
98 + passThrough: true,
99 + },
100 +];
101 +
102 +let preempts = {
103 + version: function () {
104 + program.die(ejs.VERSION);
105 + },
106 + help: function () {
107 + program.die(usage);
108 + }
109 +};
110 +
111 +let stdin = '';
112 +process.stdin.setEncoding('utf8');
113 +process.stdin.on('readable', () => {
114 + let chunk;
115 + while ((chunk = process.stdin.read()) !== null) {
116 + stdin += chunk;
117 + }
118 +});
119 +
120 +function run() {
121 +
122 + program.availableOpts = CLI_OPTS;
123 + program.parseArgs(args);
124 +
125 + let templatePath = program.taskNames[0];
126 + let pVals = program.envVars;
127 + let pOpts = {};
128 +
129 + for (let p in program.opts) {
130 + let name = hyphenToCamel(p);
131 + pOpts[name] = program.opts[p];
132 + }
133 +
134 + let opts = {};
135 + let vals = {};
136 +
137 + // Same-named 'passthrough' opts
138 + CLI_OPTS.forEach((opt) => {
139 + let optName = hyphenToCamel(opt.full);
140 + if (opt.passThrough && typeof pOpts[optName] != 'undefined') {
141 + opts[optName] = pOpts[optName];
142 + }
143 + });
144 +
145 + // Bail out for help/version
146 + for (let p in opts) {
147 + if (preempts[p]) {
148 + return preempts[p]();
149 + }
150 + }
151 +
152 + // Default to having views relative from the current working directory
153 + opts.views = ['.'];
154 +
155 + // Ensure there's a template to render
156 + if (!templatePath) {
157 + throw new Error('Please provide a template path. (Run ejs -h for help)');
158 + }
159 +
160 + if (opts.strict) {
161 + pOpts.noWith = true;
162 + }
163 + if (pOpts.noWith) {
164 + opts._with = false;
165 + }
166 +
167 + // Grab and parse any input data, in order of precedence:
168 + // 1. Stdin
169 + // 2. CLI arg via -i
170 + // 3. Data file via -f
171 + // Any individual vals passed at the end (e.g., foo=bar) will override
172 + // any vals previously set
173 + let input;
174 + let err = new Error('Please do not pass data multiple ways. Pick one of stdin, -f, or -i.');
175 + if (stdin) {
176 + input = stdin;
177 + }
178 + else if (pOpts.dataInput) {
179 + if (input) {
180 + throw err;
181 + }
182 + input = decodeURIComponent(pOpts.dataInput);
183 + }
184 + else if (pOpts.dataFile) {
185 + if (input) {
186 + throw err;
187 + }
188 + input = fs.readFileSync(pOpts.dataFile).toString();
189 + }
190 +
191 + if (input) {
192 + vals = JSON.parse(input);
193 + }
194 +
195 + // Override / set any individual values passed from the command line
196 + for (let p in pVals) {
197 + vals[p] = pVals[p];
198 + }
199 +
200 + let template = fs.readFileSync(templatePath).toString();
201 + let output = ejs.render(template, vals, opts);
202 + if (pOpts.outputFile) {
203 + fs.writeFileSync(pOpts.outputFile, output);
204 + }
205 + else {
206 + process.stdout.write(output);
207 + }
208 + process.exit();
209 +}
210 +
211 +// Defer execution so that stdin can be read if necessary
212 +setImmediate(run);
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 +var fs = require('fs');
2 +var execSync = require('child_process').execSync;
3 +var exec = function (cmd) {
4 + execSync(cmd, {stdio: 'inherit'});
5 +};
6 +
7 +/* global jake, task, desc, publishTask */
8 +
9 +task('build', ['lint', 'clean', 'browserify', 'minify'], function () {
10 + console.log('Build completed.');
11 +});
12 +
13 +desc('Cleans browerified/minified files and package files');
14 +task('clean', ['clobber'], function () {
15 + jake.rmRf('./ejs.js');
16 + jake.rmRf('./ejs.min.js');
17 + console.log('Cleaned up compiled files.');
18 +});
19 +
20 +desc('Lints the source code');
21 +task('lint', ['clean'], function () {
22 + exec('./node_modules/.bin/eslint "**/*.js"');
23 + console.log('Linting completed.');
24 +});
25 +
26 +task('browserify', function () {
27 + exec('./node_modules/browserify/bin/cmd.js --standalone ejs lib/ejs.js > ejs.js');
28 + console.log('Browserification completed.');
29 +});
30 +
31 +task('minify', function () {
32 + exec('./node_modules/uglify-js/bin/uglifyjs ejs.js > ejs.min.js');
33 + console.log('Minification completed.');
34 +});
35 +
36 +desc('Generates the EJS API docs for the public API');
37 +task('doc', function () {
38 + jake.rmRf('out');
39 + exec('./node_modules/.bin/jsdoc --verbose -c jsdoc.json lib/* docs/jsdoc/*');
40 + console.log('Documentation generated in ./out.');
41 +});
42 +
43 +desc('Generates the EJS API docs for the public and private API');
44 +task('devdoc', function () {
45 + jake.rmRf('out');
46 + exec('./node_modules/.bin/jsdoc --verbose -p -c jsdoc.json lib/* docs/jsdoc/*');
47 + console.log('Documentation generated in ./out.');
48 +});
49 +
50 +desc('Publishes the EJS API docs');
51 +task('docPublish', ['doc'], function () {
52 + fs.writeFileSync('out/CNAME', 'api.ejs.co');
53 + console.log('Pushing docs to gh-pages...');
54 + exec('./node_modules/.bin/git-directory-deploy --directory out/');
55 + console.log('Docs published to gh-pages.');
56 +});
57 +
58 +desc('Runs the EJS test suite');
59 +task('test', ['lint'], function () {
60 + exec('./node_modules/.bin/mocha');
61 +});
62 +
63 +publishTask('ejs', ['build'], function () {
64 + this.packageFiles.include([
65 + 'jakefile.js',
66 + 'README.md',
67 + 'LICENSE',
68 + 'package.json',
69 + 'ejs.js',
70 + 'ejs.min.js',
71 + 'lib/**',
72 + 'bin/**',
73 + 'usage.txt'
74 + ]);
75 +});
76 +
77 +jake.Task.publish.on('complete', function () {
78 + console.log('Updating hosted docs...');
79 + console.log('If this fails, run jake docPublish to re-try.');
80 + jake.Task.docPublish.invoke();
81 +});
This diff is collapsed. Click to expand it.
1 +/*
2 + * EJS Embedded JavaScript templates
3 + * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
4 + *
5 + * Licensed under the Apache License, Version 2.0 (the "License");
6 + * you may not use this file except in compliance with the License.
7 + * You may obtain a copy of the License at
8 + *
9 + * http://www.apache.org/licenses/LICENSE-2.0
10 + *
11 + * Unless required by applicable law or agreed to in writing, software
12 + * distributed under the License is distributed on an "AS IS" BASIS,
13 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + * See the License for the specific language governing permissions and
15 + * limitations under the License.
16 + *
17 +*/
18 +
19 +/**
20 + * Private utility functions
21 + * @module utils
22 + * @private
23 + */
24 +
25 +'use strict';
26 +
27 +var regExpChars = /[|\\{}()[\]^$+*?.]/g;
28 +
29 +/**
30 + * Escape characters reserved in regular expressions.
31 + *
32 + * If `string` is `undefined` or `null`, the empty string is returned.
33 + *
34 + * @param {String} string Input string
35 + * @return {String} Escaped string
36 + * @static
37 + * @private
38 + */
39 +exports.escapeRegExpChars = function (string) {
40 + // istanbul ignore if
41 + if (!string) {
42 + return '';
43 + }
44 + return String(string).replace(regExpChars, '\\$&');
45 +};
46 +
47 +var _ENCODE_HTML_RULES = {
48 + '&': '&amp;',
49 + '<': '&lt;',
50 + '>': '&gt;',
51 + '"': '&#34;',
52 + "'": '&#39;'
53 +};
54 +var _MATCH_HTML = /[&<>'"]/g;
55 +
56 +function encode_char(c) {
57 + return _ENCODE_HTML_RULES[c] || c;
58 +}
59 +
60 +/**
61 + * Stringified version of constants used by {@link module:utils.escapeXML}.
62 + *
63 + * It is used in the process of generating {@link ClientFunction}s.
64 + *
65 + * @readonly
66 + * @type {String}
67 + */
68 +
69 +var escapeFuncStr =
70 + 'var _ENCODE_HTML_RULES = {\n'
71 ++ ' "&": "&amp;"\n'
72 ++ ' , "<": "&lt;"\n'
73 ++ ' , ">": "&gt;"\n'
74 ++ ' , \'"\': "&#34;"\n'
75 ++ ' , "\'": "&#39;"\n'
76 ++ ' }\n'
77 ++ ' , _MATCH_HTML = /[&<>\'"]/g;\n'
78 ++ 'function encode_char(c) {\n'
79 ++ ' return _ENCODE_HTML_RULES[c] || c;\n'
80 ++ '};\n';
81 +
82 +/**
83 + * Escape characters reserved in XML.
84 + *
85 + * If `markup` is `undefined` or `null`, the empty string is returned.
86 + *
87 + * @implements {EscapeCallback}
88 + * @param {String} markup Input string
89 + * @return {String} Escaped string
90 + * @static
91 + * @private
92 + */
93 +
94 +exports.escapeXML = function (markup) {
95 + return markup == undefined
96 + ? ''
97 + : String(markup)
98 + .replace(_MATCH_HTML, encode_char);
99 +};
100 +exports.escapeXML.toString = function () {
101 + return Function.prototype.toString.call(this) + ';\n' + escapeFuncStr;
102 +};
103 +
104 +/**
105 + * Naive copy of properties from one object to another.
106 + * Does not recurse into non-scalar properties
107 + * Does not check to see if the property has a value before copying
108 + *
109 + * @param {Object} to Destination object
110 + * @param {Object} from Source object
111 + * @return {Object} Destination object
112 + * @static
113 + * @private
114 + */
115 +exports.shallowCopy = function (to, from) {
116 + from = from || {};
117 + for (var p in from) {
118 + to[p] = from[p];
119 + }
120 + return to;
121 +};
122 +
123 +/**
124 + * Naive copy of a list of key names, from one object to another.
125 + * Only copies property if it is actually defined
126 + * Does not recurse into non-scalar properties
127 + *
128 + * @param {Object} to Destination object
129 + * @param {Object} from Source object
130 + * @param {Array} list List of properties to copy
131 + * @return {Object} Destination object
132 + * @static
133 + * @private
134 + */
135 +exports.shallowCopyFromList = function (to, from, list) {
136 + for (var i = 0; i < list.length; i++) {
137 + var p = list[i];
138 + if (typeof from[p] != 'undefined') {
139 + to[p] = from[p];
140 + }
141 + }
142 + return to;
143 +};
144 +
145 +/**
146 + * Simple in-process cache implementation. Does not implement limits of any
147 + * sort.
148 + *
149 + * @implements {Cache}
150 + * @static
151 + * @private
152 + */
153 +exports.cache = {
154 + _data: {},
155 + set: function (key, val) {
156 + this._data[key] = val;
157 + },
158 + get: function (key) {
159 + return this._data[key];
160 + },
161 + remove: function (key) {
162 + delete this._data[key];
163 + },
164 + reset: function () {
165 + this._data = {};
166 + }
167 +};
168 +
169 +/**
170 + * Transforms hyphen case variable into camel case.
171 + *
172 + * @param {String} string Hyphen case string
173 + * @return {String} Camel case string
174 + * @static
175 + * @private
176 + */
177 +exports.hyphenToCamel = function (str) {
178 + return str.replace(/-[a-z]/g, function (match) { return match[1].toUpperCase(); });
179 +};
1 +{
2 + "name": "ejs",
3 + "description": "Embedded JavaScript templates",
4 + "keywords": [
5 + "template",
6 + "engine",
7 + "ejs"
8 + ],
9 + "version": "3.1.6",
10 + "author": "Matthew Eernisse <mde@fleegix.org> (http://fleegix.org)",
11 + "license": "Apache-2.0",
12 + "bin": {
13 + "ejs": "./bin/cli.js"
14 + },
15 + "main": "./lib/ejs.js",
16 + "jsdelivr": "ejs.min.js",
17 + "unpkg": "ejs.min.js",
18 + "repository": {
19 + "type": "git",
20 + "url": "git://github.com/mde/ejs.git"
21 + },
22 + "bugs": "https://github.com/mde/ejs/issues",
23 + "homepage": "https://github.com/mde/ejs",
24 + "dependencies": {
25 + "jake": "^10.6.1"
26 + },
27 + "devDependencies": {
28 + "browserify": "^16.5.1",
29 + "eslint": "^6.8.0",
30 + "git-directory-deploy": "^1.5.1",
31 + "jsdoc": "^3.6.4",
32 + "lru-cache": "^4.0.1",
33 + "mocha": "^7.1.1",
34 + "uglify-js": "^3.3.16"
35 + },
36 + "engines": {
37 + "node": ">=0.10.0"
38 + },
39 + "scripts": {
40 + "test": "mocha"
41 + }
42 +}
1 +EJS Embedded JavaScript templates
2 +{Usage}: ejs [options ...] template-file [data variables ...]
3 +
4 +{Options}:
5 + -o, --output-file FILE Write the rendered output to FILE rather than stdout.
6 + -f, --data-file FILE Must be JSON-formatted. Use parsed input from FILE as data for rendering.
7 + -i, --data-input STRING Must be JSON-formatted and URI-encoded. Use parsed input from STRING as data for rendering.
8 + -m, --delimiter CHARACTER Use CHARACTER with angle brackets for open/close (defaults to %).
9 + -p, --open-delimiter CHARACTER Use CHARACTER instead of left angle bracket to open.
10 + -c, --close-delimiter CHARACTER Use CHARACTER instead of right angle bracket to close.
11 + -s, --strict When set to `true`, generated function is in strict mode
12 + -n --no-with Use 'locals' object for vars rather than using `with` (implies --strict).
13 + -l --locals-name Name to use for the object storing local variables when not using `with`.
14 + -w --rm-whitespace Remove all safe-to-remove whitespace, including leading and trailing whitespace.
15 + -d --debug Outputs generated function body
16 + -h, --help Display this help message.
17 + -V/v, --version Display the EJS version.
18 +
19 +{Examples}:
20 + ejs -m $ ./test/fixtures/user.ejs -f ./user_data.json
21 + ejs -m $ ./test/fixtures/user.ejs name=Lerxst
22 + ejs -p [ -c ] ./template_file.ejs -o ./output.html
23 + ejs -n -l _ ./some_template.ejs -f ./data_file.json
24 + ejs -w ./template_with_whitspace.ejs -o ./output_file.html
1 +'use strict';
2 +
3 +var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
4 +
5 +module.exports = function (str) {
6 + if (typeof str !== 'string') {
7 + throw new TypeError('Expected a string');
8 + }
9 +
10 + return str.replace(matchOperatorsRe, '\\$&');
11 +};
1 +The MIT License (MIT)
2 +
3 +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in
13 +all copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 +THE SOFTWARE.
1 +{
2 + "name": "escape-string-regexp",
3 + "version": "1.0.5",
4 + "description": "Escape RegExp special characters",
5 + "license": "MIT",
6 + "repository": "sindresorhus/escape-string-regexp",
7 + "author": {
8 + "name": "Sindre Sorhus",
9 + "email": "sindresorhus@gmail.com",
10 + "url": "sindresorhus.com"
11 + },
12 + "maintainers": [
13 + "Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)",
14 + "Joshua Boy Nicolai Appelman <joshua@jbna.nl> (jbna.nl)"
15 + ],
16 + "engines": {
17 + "node": ">=0.8.0"
18 + },
19 + "scripts": {
20 + "test": "xo && ava"
21 + },
22 + "files": [
23 + "index.js"
24 + ],
25 + "keywords": [
26 + "escape",
27 + "regex",
28 + "regexp",
29 + "re",
30 + "regular",
31 + "expression",
32 + "string",
33 + "str",
34 + "special",
35 + "characters"
36 + ],
37 + "devDependencies": {
38 + "ava": "*",
39 + "xo": "*"
40 + }
41 +}
1 +# escape-string-regexp [![Build Status](https://travis-ci.org/sindresorhus/escape-string-regexp.svg?branch=master)](https://travis-ci.org/sindresorhus/escape-string-regexp)
2 +
3 +> Escape RegExp special characters
4 +
5 +
6 +## Install
7 +
8 +```
9 +$ npm install --save escape-string-regexp
10 +```
11 +
12 +
13 +## Usage
14 +
15 +```js
16 +const escapeStringRegexp = require('escape-string-regexp');
17 +
18 +const escapedString = escapeStringRegexp('how much $ for a unicorn?');
19 +//=> 'how much \$ for a unicorn\?'
20 +
21 +new RegExp(escapedString);
22 +```
23 +
24 +
25 +## License
26 +
27 +MIT © [Sindre Sorhus](http://sindresorhus.com)
1 +## FileList
2 +
3 +A FileList is a lazy-evaluated list of files. When given a list
4 +of glob patterns for possible files to be included in the file
5 +list, instead of searching the file structures to find the files,
6 +a FileList holds the pattern for latter use.
7 +
8 +This allows you to define a FileList to match any number of
9 +files, but only search out the actual files when then FileList
10 +itself is actually used. The key is that the first time an
11 +element of the FileList/Array is requested, the pending patterns
12 +are resolved into a real list of file names.
13 +
14 +### Usage
15 +
16 +Add files to the list with the `include` method. You can add glob
17 +patterns, individual files, or RegExp objects. When the Array
18 +methods are invoked on the FileList, these items are resolved to
19 +an actual list of files.
20 +
21 +```javascript
22 +var fl = new FileList();
23 +fl.include('test/*.js');
24 +fl.exclude('test/helpers.js');
25 +```
26 +
27 +Use the `exclude` method to override inclusions. You can use this
28 +when your inclusions are too broad.
29 +
30 +### Array methods
31 +
32 +FileList has lazy-evaluated versions of most of the array
33 +methods, including the following:
34 +
35 +* join
36 +* pop
37 +* push
38 +* concat
39 +* reverse
40 +* shift
41 +* unshift
42 +* slice
43 +* splice
44 +* sort
45 +* filter
46 +* forEach
47 +* some
48 +* every
49 +* map
50 +* indexOf
51 +* lastIndexOf
52 +* reduce
53 +* reduceRight
54 +
55 +When you call one of these methods, the items in the FileList
56 +will be resolved to the full list of files, and the method will
57 +be invoked on that result.
58 +
59 +### Special `length` method
60 +
61 +`length`: FileList includes a length *method* (instead of a
62 +property) which returns the number of actual files in the list
63 +once it's been resolved.
64 +
65 +### FileList-specific methods
66 +
67 +`include`: Add a filename/glob/regex to the list
68 +
69 +`exclude`: Override inclusions by excluding a filename/glob/regex
70 +
71 +`resolve`: Resolve the items in the FileList to the full list of
72 +files. This method is invoked automatically when one of the array
73 +methods is called.
74 +
75 +`toArray`: Immediately resolves the list of items, and returns an
76 +actual array of filepaths.
77 +
78 +`clearInclusions`: Clears any pending items -- must be used
79 +before resolving the list.
80 +
81 +`clearExclusions`: Clears the list of exclusions rules.
82 +
83 +
84 +
1 +// Type definitions for filelist v0.0.6
2 +// Project: https://github.com/mde/filelist
3 +// Definitions by: Christophe MASSOLIN <https://github.com/FuriouZz>
4 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5 +
6 +declare module "filelist" {
7 + export class FileList {
8 + pendingAdd: string[]
9 + pending: boolean
10 + excludes: {
11 + pats: RegExp[],
12 + funcs: Function[],
13 + regex: null | RegExp
14 + }
15 + items: string[]
16 + static clone(): FileList
17 + static verbose: boolean
18 + toArray(): string[]
19 + include(options: any, ...items: string[]): void
20 + exclude(...items: string[]): void
21 + resolve(): void
22 + clearInclusions(): void
23 + clearExclusions(): void
24 + length(): number
25 + toString(): string;
26 + toLocaleString(): string;
27 + push(...items: string[]): number;
28 + pop(): string | undefined;
29 + concat(...items: ReadonlyArray<string>[]): string[];
30 + concat(...items: (string | ReadonlyArray<string>)[]): string[];
31 + join(separator?: string): string;
32 + reverse(): string[];
33 + shift(): string | undefined;
34 + slice(start?: number, end?: number): string[];
35 + sort(compareFn?: (a: string, b: string) => number): this;
36 + splice(start: number, deleteCount?: number): string[];
37 + splice(start: number, deleteCount: number, ...items: string[]): string[];
38 + unshift(...items: string[]): number;
39 + indexOf(searchElement: string, fromIndex?: number): number;
40 + lastIndexOf(searchElement: string, fromIndex?: number): number;
41 + every(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean;
42 + some(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean;
43 + forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void;
44 + map<U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[];
45 + filter<S extends string>(callbackfn: (value: string, index: number, array: string[]) => value is S, thisArg?: any): S[];
46 + filter(callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any): string[];
47 + reduce(callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string;
48 + reduce(callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string;
49 + reduce<U>(callbackfn: (previousValue: U, currentValue: string, currentIndex: number, array: string[]) => U, initialValue: U): U;
50 + reduceRight(callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string;
51 + reduceRight(callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string;
52 + reduceRight<U>(callbackfn: (previousValue: U, currentValue: string, currentIndex: number, array: string[]) => U, initialValue: U): U;
53 + }
54 +}
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
1 +testTask('FileList', function () {
2 + this.testFiles.include('test/*.js');
3 +});
4 +
5 +publishTask('FileList', function () {
6 + this.packageFiles.include([
7 + 'jakefile.js',
8 + 'README.md',
9 + 'package.json',
10 + 'index.js',
11 + 'index.d.ts'
12 + ]);
13 +});
14 +
15 +
1 +{
2 + "name": "filelist",
3 + "version": "1.0.2",
4 + "description": "Lazy-evaluating list of files, based on globs or regex patterns",
5 + "main": "index.js",
6 + "types": "index.d.ts",
7 + "scripts": {
8 + "test": "jake test"
9 + },
10 + "repository": {
11 + "type": "git",
12 + "url": "git://github.com/mde/filelist.git"
13 + },
14 + "keywords": [
15 + "file",
16 + "utility",
17 + "glob"
18 + ],
19 + "author": "Matthew Eernisse <mde@fleegix.org> (http://fleegix.org)",
20 + "license": "Apache-2.0",
21 + "bugs": {
22 + "url": "https://github.com/mde/filelist/issues"
23 + },
24 + "homepage": "https://github.com/mde/filelist",
25 + "dependencies": {
26 + "minimatch": "^3.0.4"
27 + }
28 +}
1 +'use strict';
2 +module.exports = (flag, argv) => {
3 + argv = argv || process.argv;
4 + const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
5 + const pos = argv.indexOf(prefix + flag);
6 + const terminatorPos = argv.indexOf('--');
7 + return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
8 +};
1 +MIT License
2 +
3 +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4 +
5 +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:
6 +
7 +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 +
9 +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.
1 +{
2 + "name": "has-flag",
3 + "version": "3.0.0",
4 + "description": "Check if argv has a specific flag",
5 + "license": "MIT",
6 + "repository": "sindresorhus/has-flag",
7 + "author": {
8 + "name": "Sindre Sorhus",
9 + "email": "sindresorhus@gmail.com",
10 + "url": "sindresorhus.com"
11 + },
12 + "engines": {
13 + "node": ">=4"
14 + },
15 + "scripts": {
16 + "test": "xo && ava"
17 + },
18 + "files": [
19 + "index.js"
20 + ],
21 + "keywords": [
22 + "has",
23 + "check",
24 + "detect",
25 + "contains",
26 + "find",
27 + "flag",
28 + "cli",
29 + "command-line",
30 + "argv",
31 + "process",
32 + "arg",
33 + "args",
34 + "argument",
35 + "arguments",
36 + "getopt",
37 + "minimist",
38 + "optimist"
39 + ],
40 + "devDependencies": {
41 + "ava": "*",
42 + "xo": "*"
43 + }
44 +}
1 +# has-flag [![Build Status](https://travis-ci.org/sindresorhus/has-flag.svg?branch=master)](https://travis-ci.org/sindresorhus/has-flag)
2 +
3 +> Check if [`argv`](https://nodejs.org/docs/latest/api/process.html#process_process_argv) has a specific flag
4 +
5 +Correctly stops looking after an `--` argument terminator.
6 +
7 +
8 +## Install
9 +
10 +```
11 +$ npm install has-flag
12 +```
13 +
14 +
15 +## Usage
16 +
17 +```js
18 +// foo.js
19 +const hasFlag = require('has-flag');
20 +
21 +hasFlag('unicorn');
22 +//=> true
23 +
24 +hasFlag('--unicorn');
25 +//=> true
26 +
27 +hasFlag('f');
28 +//=> true
29 +
30 +hasFlag('-f');
31 +//=> true
32 +
33 +hasFlag('foo=bar');
34 +//=> true
35 +
36 +hasFlag('foo');
37 +//=> false
38 +
39 +hasFlag('rainbow');
40 +//=> false
41 +```
42 +
43 +```
44 +$ node foo.js -f --unicorn --foo=bar -- --rainbow
45 +```
46 +
47 +
48 +## API
49 +
50 +### hasFlag(flag, [argv])
51 +
52 +Returns a boolean for whether the flag exists.
53 +
54 +#### flag
55 +
56 +Type: `string`
57 +
58 +CLI flag to look for. The `--` prefix is optional.
59 +
60 +#### argv
61 +
62 +Type: `string[]`<br>
63 +Default: `process.argv`
64 +
65 +CLI arguments.
66 +
67 +
68 +## License
69 +
70 +MIT © [Sindre Sorhus](https://sindresorhus.com)
1 +#
2 +# Jake JavaScript build tool
3 +# Copyright 2112 Matthew Eernisse (mde@fleegix.org)
4 +#
5 +# Licensed under the Apache License, Version 2.0 (the "License");
6 +# you may not use this file except in compliance with the License.
7 +# You may obtain a copy of the License at
8 +#
9 +# http://www.apache.org/licenses/LICENSE-2.0
10 +#
11 +# Unless required by applicable law or agreed to in writing, software
12 +# distributed under the License is distributed on an "AS IS" BASIS,
13 +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 +# See the License for the specific language governing permissions and
15 +# limitations under the License.
16 +#
17 +
18 +.PHONY: all build install clean uninstall
19 +
20 +PREFIX=/usr/local
21 +DESTDIR=
22 +
23 +all: build
24 +
25 +build:
26 + @echo 'Jake built.'
27 +
28 +install:
29 + @mkdir -p $(DESTDIR)$(PREFIX)/bin && \
30 + mkdir -p $(DESTDIR)$(PREFIX)/lib/node_modules/jake && \
31 + mkdir -p ./node_modules && \
32 + npm install utilities minimatch && \
33 + cp -R ./* $(DESTDIR)$(PREFIX)/lib/node_modules/jake/ && \
34 + ln -snf ../lib/node_modules/jake/bin/cli.js $(DESTDIR)$(PREFIX)/bin/jake && \
35 + chmod 755 $(DESTDIR)$(PREFIX)/lib/node_modules/jake/bin/cli.js && \
36 + echo 'Jake installed.'
37 +
38 +clean:
39 + @true
40 +
41 +uninstall:
42 + @rm -f $(DESTDIR)$(PREFIX)/bin/jake && \
43 + rm -fr $(DESTDIR)$(PREFIX)/lib/node_modules/jake/ && \
44 + echo 'Jake uninstalled.'
1 +### Jake -- the JavaScript build tool for Node.js
2 +
3 +[![Build Status](https://travis-ci.org/jakejs/jake.svg?branch=master)](https://travis-ci.org/jakejs/jake)
4 +
5 +Documentation site at [http://jakejs.com](http://jakejs.com/)
6 +
7 +### Contributing
8 +1. [Install node](http://nodejs.org/#download).
9 +2. Clone this repository `$ git clone git@github.com:jakejs/jake.git`.
10 +3. Install dependencies `$ npm install`.
11 +4. Run tests with `$ npm test`.
12 +5. Start Hacking!
13 +
14 +### License
15 +
16 +Licensed under the Apache License, Version 2.0
17 +(<http://www.apache.org/licenses/LICENSE-2.0>)
1 +#!/bin/bash
2 +
3 +# http://stackoverflow.com/a/246128
4 +SOURCE="${BASH_SOURCE[0]}"
5 +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
6 + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
7 + SOURCE="$(readlink "$SOURCE")"
8 + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
9 +done
10 +JAKE_BIN_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
11 +
12 +# http://stackoverflow.com/a/12495480
13 +# http://stackoverflow.com/a/28647824
14 +_auto_jake()
15 +{
16 + local cur
17 + local -a COMPGEN=()
18 + _get_comp_words_by_ref -n : -c cur
19 +
20 + # run auto-completions in jake via our auto_complete.js wrapper
21 + local -a auto_complete_info=( $(export COMP_LINE="${COMP_LINE}" && ${JAKE_BIN_DIR}/auto_complete.js "$cur" "${3}") )
22 + # check reply flag
23 + local reply_flag="${auto_complete_info[0]}"
24 + if [[ "${reply_flag}" == "no-complete" ]]; then
25 + return 1
26 + fi
27 + local auto_completions=("${auto_complete_info[@]:1}")
28 + COMPGEN=( $(compgen -W "${auto_completions[*]}" -- "$cur") )
29 + COMPREPLY=( "${COMPGEN[@]}" )
30 +
31 + __ltrim_colon_completions "$cur"
32 +
33 + # do we need another space??
34 + if [[ "${reply_flag}" == "yes-space" ]]; then
35 + COMPREPLY=( "${COMPGEN[@]}" " " )
36 + fi
37 +
38 + return 0
39 +}
40 +
41 +complete -o default -F _auto_jake jake
1 +#!/usr/bin/env node
2 +/*
3 + * Jake JavaScript build tool
4 + * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
5 + *
6 + * Licensed under the Apache License, Version 2.0 (the "License");
7 + * you may not use this file except in compliance with the License.
8 + * You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing, software
13 + * distributed under the License is distributed on an "AS IS" BASIS,
14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 + * See the License for the specific language governing permissions and
16 + * limitations under the License.
17 + *
18 +*/
19 +
20 +// Try to load a local jake
21 +try {
22 + require(`${ process.cwd() }/node_modules/jake`);
23 +}
24 +// If that fails, likely running globally
25 +catch(e) {
26 + require('../lib/jake');
27 +}
28 +
29 +var args = process.argv.slice(2);
30 +
31 +jake.run.apply(jake, args);
1 +let fs = require('fs')
2 +let path = require('path');
3 +let proc = require('child_process');
4 +
5 +const PROJECT_DIR = process.cwd();
6 +process.env.PROJECT_DIR = PROJECT_DIR;
7 +
8 +namespace('doc', function () {
9 + task('generate', ['doc:clobber'], function () {
10 + var cmd = '../node-jsdoc-toolkit/app/run.js -n -r=100 ' +
11 + '-t=../node-jsdoc-toolkit/templates/codeview -d=./doc/ ./lib';
12 + jake.logger.log('Generating docs ...');
13 + jake.exec([cmd], function () {
14 + jake.logger.log('Done.');
15 + complete();
16 + });
17 + }, {async: true});
18 +
19 + task('clobber', function () {
20 + var cmd = 'rm -fr ./doc/*';
21 + jake.exec([cmd], function () {
22 + jake.logger.log('Clobbered old docs.');
23 + complete();
24 + });
25 + }, {async: true});
26 +
27 +});
28 +
29 +desc('Generate docs for Jake');
30 +task('doc', ['doc:generate']);
31 +
32 +npmPublishTask('jake', function () {
33 + this.packageFiles.include([
34 + 'Makefile',
35 + 'jakefile.js',
36 + 'README.md',
37 + 'package.json',
38 + 'usage.txt',
39 + 'lib/**',
40 + 'bin/**',
41 + 'test/**'
42 + ]);
43 + this.packageFiles.exclude([
44 + 'test/tmp'
45 + ]);
46 +});
47 +
48 +jake.Task['publish:package'].directory = PROJECT_DIR;
49 +
50 +namespace('test', function () {
51 +
52 + let integrationTest = task('integration', ['publish:package'], async function () {
53 + let pkg = JSON.parse(fs.readFileSync(`${PROJECT_DIR}/package.json`).toString());
54 + let version = pkg.version;
55 +
56 + proc.execSync('rm -rf ./node_modules');
57 + // Install from the actual package, run tests from the packaged binary
58 + proc.execSync(`mkdir -p node_modules/.bin && mv ${PROJECT_DIR}/pkg/jake-v` +
59 + `${version} node_modules/jake && ln -s ${process.cwd()}` +
60 + '/node_modules/jake/bin/cli.js ./node_modules/.bin/jake');
61 +
62 + let testArgs = [];
63 + if (process.env.filter) {
64 + testArgs.push(process.env.filter);
65 + }
66 + else {
67 + testArgs.push('*.js');
68 + }
69 + let spawned = proc.spawn(`${PROJECT_DIR}/node_modules/.bin/mocha`, testArgs, {
70 + stdio: 'inherit'
71 + });
72 + return new Promise((resolve, reject) => {
73 + spawned.on('exit', () => {
74 + if (!(process.env.noclobber || process.env.noClobber)) {
75 + proc.execSync('rm -rf tmp_publish && rm -rf package.json' +
76 + ' && rm -rf package-lock.json && rm -rf node_modules');
77 + // Rather than invoking 'clobber' task
78 + jake.rmRf(`${PROJECT_DIR}/pkg`);
79 + }
80 + resolve();
81 + });
82 + });
83 +
84 + });
85 +
86 + integrationTest.directory = `${PROJECT_DIR}/test/integration`;
87 +
88 + let unitTest = task('unit', async function () {
89 + let testArgs = [];
90 + if (process.env.filter) {
91 + testArgs.push(process.env.filter);
92 + }
93 + else {
94 + testArgs.push('*.js');
95 + }
96 + let spawned = proc.spawn(`${PROJECT_DIR}/node_modules/.bin/mocha`, testArgs, {
97 + stdio: 'inherit'
98 + });
99 + });
100 +
101 + unitTest.directory = `${PROJECT_DIR}/test/unit`;
102 +});
103 +
104 +desc('Runs all tests');
105 +task('test', ['test:unit', 'test:integration']);
This diff is collapsed. Click to expand it.
1 +/*
2 + * Jake JavaScript build tool
3 + * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
4 + *
5 + * Licensed under the Apache License, Version 2.0 (the "License");
6 + * you may not use this file except in compliance with the License.
7 + * You may obtain a copy of the License at
8 + *
9 + * http://www.apache.org/licenses/LICENSE-2.0
10 + *
11 + * Unless required by applicable law or agreed to in writing, software
12 + * distributed under the License is distributed on an "AS IS" BASIS,
13 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + * See the License for the specific language governing permissions and
15 + * limitations under the License.
16 + *
17 +*/
18 +
19 +if (!global.jake) {
20 +
21 + let EventEmitter = require('events').EventEmitter;
22 + // And so it begins
23 + global.jake = new EventEmitter();
24 +
25 + let fs = require('fs');
26 + let chalk = require('chalk');
27 + let taskNs = require('./task');
28 + let Task = taskNs.Task;
29 + let FileTask = taskNs.FileTask;
30 + let DirectoryTask = taskNs.DirectoryTask;
31 + let Rule = require('./rule').Rule;
32 + let Namespace = require('./namespace').Namespace;
33 + let RootNamespace = require('./namespace').RootNamespace;
34 + let api = require('./api');
35 + let utils = require('./utils');
36 + let Program = require('./program').Program;
37 + let loader = require('./loader')();
38 + let pkg = JSON.parse(fs.readFileSync(__dirname + '/../package.json').toString());
39 +
40 + const MAX_RULE_RECURSION_LEVEL = 16;
41 +
42 + // Globalize jake and top-level API methods (e.g., `task`, `desc`)
43 + Object.assign(global, api);
44 +
45 + // Copy utils onto base jake
46 + jake.logger = utils.logger;
47 + jake.exec = utils.exec;
48 +
49 + // File utils should be aliased directly on base jake as well
50 + Object.assign(jake, utils.file);
51 +
52 + // Also add top-level API methods to exported object for those who don't want to
53 + // use the globals (`file` here will overwrite the 'file' utils namespace)
54 + Object.assign(jake, api);
55 +
56 + Object.assign(jake, new (function () {
57 +
58 + this._invocationChain = [];
59 + this._taskTimeout = 30000;
60 +
61 + // Public properties
62 + // =================
63 + this.version = pkg.version;
64 + // Used when Jake exits with a specific error-code
65 + this.errorCode = null;
66 + // Loads Jakefiles/jakelibdirs
67 + this.loader = loader;
68 + // The root of all ... namespaces
69 + this.rootNamespace = new RootNamespace();
70 + // Non-namespaced tasks are placed into the default
71 + this.defaultNamespace = this.rootNamespace;
72 + // Start in the default
73 + this.currentNamespace = this.defaultNamespace;
74 + // Saves the description created by a 'desc' call that prefaces a
75 + // 'task' call that defines a task.
76 + this.currentTaskDescription = null;
77 + this.program = new Program();
78 + this.FileList = require('filelist').FileList;
79 + this.PackageTask = require('./package_task').PackageTask;
80 + this.PublishTask = require('./publish_task').PublishTask;
81 + this.TestTask = require('./test_task').TestTask;
82 + this.Task = Task;
83 + this.FileTask = FileTask;
84 + this.DirectoryTask = DirectoryTask;
85 + this.Namespace = Namespace;
86 + this.Rule = Rule;
87 +
88 + this.parseAllTasks = function () {
89 + let _parseNs = function (ns) {
90 + let nsTasks = ns.tasks;
91 + let nsNamespaces = ns.childNamespaces;
92 + for (let q in nsTasks) {
93 + let nsTask = nsTasks[q];
94 + jake.Task[nsTask.fullName] = nsTask;
95 + }
96 + for (let p in nsNamespaces) {
97 + let nsNamespace = nsNamespaces[p];
98 + _parseNs(nsNamespace);
99 + }
100 + };
101 + _parseNs(jake.defaultNamespace);
102 + };
103 +
104 + /**
105 + * Displays the list of descriptions avaliable for tasks defined in
106 + * a Jakefile
107 + */
108 + this.showAllTaskDescriptions = function (f) {
109 + let p;
110 + let maxTaskNameLength = 0;
111 + let task;
112 + let padding;
113 + let name;
114 + let descr;
115 + let filter = typeof f == 'string' ? f : null;
116 +
117 + for (p in jake.Task) {
118 + if (!Object.prototype.hasOwnProperty.call(jake.Task, p)) {
119 + continue;
120 + }
121 + if (filter && p.indexOf(filter) == -1) {
122 + continue;
123 + }
124 + task = jake.Task[p];
125 + // Record the length of the longest task name -- used for
126 + // pretty alignment of the task descriptions
127 + if (task.description) {
128 + maxTaskNameLength = p.length > maxTaskNameLength ?
129 + p.length : maxTaskNameLength;
130 + }
131 + }
132 + // Print out each entry with descriptions neatly aligned
133 + for (p in jake.Task) {
134 + if (!Object.prototype.hasOwnProperty.call(jake.Task, p)) {
135 + continue;
136 + }
137 + if (filter && p.indexOf(filter) == -1) {
138 + continue;
139 + }
140 + task = jake.Task[p];
141 +
142 + //name = '\033[32m' + p + '\033[39m ';
143 + name = chalk.green(p);
144 +
145 + descr = task.description;
146 + if (descr) {
147 + descr = chalk.gray('# ' + descr);
148 +
149 + // Create padding-string with calculated length
150 + padding = (new Array(maxTaskNameLength - p.length + 2)).join(' ');
151 +
152 + console.log('jake ' + name + padding + descr);
153 + }
154 + }
155 + };
156 +
157 + this.createTask = function () {
158 + let args = Array.prototype.slice.call(arguments);
159 + let arg;
160 + let obj;
161 + let task;
162 + let type;
163 + let name;
164 + let action;
165 + let opts = {};
166 + let prereqs = [];
167 +
168 + type = args.shift();
169 +
170 + // name, [deps], [action]
171 + // Name (string) + deps (array) format
172 + if (typeof args[0] == 'string') {
173 + name = args.shift();
174 + if (Array.isArray(args[0])) {
175 + prereqs = args.shift();
176 + }
177 + }
178 + // name:deps, [action]
179 + // Legacy object-literal syntax, e.g.: {'name': ['depA', 'depB']}
180 + else {
181 + obj = args.shift();
182 + for (let p in obj) {
183 + prereqs = prereqs.concat(obj[p]);
184 + name = p;
185 + }
186 + }
187 +
188 + // Optional opts/callback or callback/opts
189 + while ((arg = args.shift())) {
190 + if (typeof arg == 'function') {
191 + action = arg;
192 + }
193 + else {
194 + opts = Object.assign(Object.create(null), arg);
195 + }
196 + }
197 +
198 + task = jake.currentNamespace.resolveTask(name);
199 + if (task && !action) {
200 + // Task already exists and no action, just update prereqs, and return it.
201 + task.prereqs = task.prereqs.concat(prereqs);
202 + return task;
203 + }
204 +
205 + switch (type) {
206 + case 'directory':
207 + action = function () {
208 + jake.mkdirP(name);
209 + };
210 + task = new DirectoryTask(name, prereqs, action, opts);
211 + break;
212 + case 'file':
213 + task = new FileTask(name, prereqs, action, opts);
214 + break;
215 + default:
216 + task = new Task(name, prereqs, action, opts);
217 + }
218 +
219 + jake.currentNamespace.addTask(task);
220 +
221 + if (jake.currentTaskDescription) {
222 + task.description = jake.currentTaskDescription;
223 + jake.currentTaskDescription = null;
224 + }
225 +
226 + // FIXME: Should only need to add a new entry for the current
227 + // task-definition, not reparse the entire structure
228 + jake.parseAllTasks();
229 +
230 + return task;
231 + };
232 +
233 + this.attemptRule = function (name, ns, level) {
234 + let prereqRule;
235 + let prereq;
236 + if (level > MAX_RULE_RECURSION_LEVEL) {
237 + return null;
238 + }
239 + // Check Rule
240 + prereqRule = ns.matchRule(name);
241 + if (prereqRule) {
242 + prereq = prereqRule.createTask(name, level);
243 + }
244 + return prereq || null;
245 + };
246 +
247 + this.createPlaceholderFileTask = function (name, namespace) {
248 + let parsed = name.split(':');
249 + let filePath = parsed.pop(); // Strip any namespace
250 + let task;
251 +
252 + task = namespace.resolveTask(name);
253 +
254 + // If there's not already an existing dummy FileTask for it,
255 + // create one
256 + if (!task) {
257 + // Create a dummy FileTask only if file actually exists
258 + if (fs.existsSync(filePath)) {
259 + task = new jake.FileTask(filePath);
260 + task.dummy = true;
261 + let ns;
262 + if (parsed.length) {
263 + ns = namespace.resolveNamespace(parsed.join(':'));
264 + }
265 + else {
266 + ns = namespace;
267 + }
268 + if (!namespace) {
269 + throw new Error('Invalid namespace, cannot add FileTask');
270 + }
271 + ns.addTask(task);
272 + // Put this dummy Task in the global Tasks list so
273 + // modTime will be eval'd correctly
274 + jake.Task[`${ns.path}:${filePath}`] = task;
275 + }
276 + }
277 +
278 + return task || null;
279 + };
280 +
281 +
282 + this.run = function () {
283 + let args = Array.prototype.slice.call(arguments);
284 + let program = this.program;
285 + let loader = this.loader;
286 + let preempt;
287 + let opts;
288 +
289 + program.parseArgs(args);
290 + program.init();
291 +
292 + preempt = program.firstPreemptiveOption();
293 + if (preempt) {
294 + preempt();
295 + }
296 + else {
297 + opts = program.opts;
298 + // jakefile flag set but no jakefile yet
299 + if (opts.autocomplete && opts.jakefile === true) {
300 + process.stdout.write('no-complete');
301 + return;
302 + }
303 + // Load Jakefile and jakelibdir files
304 + let jakefileLoaded = loader.loadFile(opts.jakefile);
305 + let jakelibdirLoaded = loader.loadDirectory(opts.jakelibdir);
306 +
307 + if(!jakefileLoaded && !jakelibdirLoaded && !opts.autocomplete) {
308 + fail('No Jakefile. Specify a valid path with -f/--jakefile, ' +
309 + 'or place one in the current directory.');
310 + }
311 +
312 + program.run();
313 + }
314 + };
315 +
316 + })());
317 +}
318 +
319 +module.exports = jake;
1 +/*
2 + * Jake JavaScript build tool
3 + * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
4 + *
5 + * Licensed under the Apache License, Version 2.0 (the "License");
6 + * you may not use this file except in compliance with the License.
7 + * You may obtain a copy of the License at
8 + *
9 + * http://www.apache.org/licenses/LICENSE-2.0
10 + *
11 + * Unless required by applicable law or agreed to in writing, software
12 + * distributed under the License is distributed on an "AS IS" BASIS,
13 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + * See the License for the specific language governing permissions and
15 + * limitations under the License.
16 + *
17 +*/
18 +
19 +let path = require('path');
20 +let fs = require('fs');
21 +let existsSync = fs.existsSync;
22 +let utils = require('./utils');
23 +
24 +// Files like jakelib/foobar.jake.js
25 +const JAKELIB_FILE_PAT = /\.jake$|\.js$/;
26 +const SUPPORTED_EXTENSIONS = {
27 + 'js': null,
28 + 'coffee': function () {
29 + try {
30 + let cs = require('coffeescript');
31 + if (typeof cs.register == 'function') {
32 + cs.register();
33 + }
34 + }
35 + catch(e) {
36 + throw new Error('You have a CoffeeScript Jakefile, but have not installed CoffeeScript');
37 + }
38 + },
39 + 'ls': function () {
40 + try {
41 + require('livescript');
42 + }
43 + catch (e) {
44 + throw new Error('You have a LiveScript Jakefile, but have not installed LiveScript');
45 + }
46 + }
47 +};
48 +const IMPLICIT_JAKEFILE_NAMES = [
49 + 'Jakefile',
50 + 'Gulpfile'
51 +];
52 +
53 +let Loader = function () {
54 + // Load a Jakefile, running the code inside -- this may result in
55 + // tasks getting defined using the original Jake API, e.g.,
56 + // `task('foo' ['bar', 'baz']);`, or can also auto-create tasks
57 + // from any functions exported from the file
58 + function loadFile(filePath) {
59 + let exported = require(filePath);
60 + for (let [key, value] of Object.entries(exported)) {
61 + let t;
62 + if (typeof value == 'function') {
63 + t = jake.task(key, value);
64 + t.description = '(Exported function)';
65 + }
66 + }
67 + }
68 +
69 + function fileExists(name) {
70 + let nameWithExt = null;
71 + // Support no file extension as well
72 + let exts = Object.keys(SUPPORTED_EXTENSIONS).concat(['']);
73 + exts.some((ext) => {
74 + let fname = ext ? `${name}.${ext}` : name;
75 + if (existsSync(fname)) {
76 + nameWithExt = fname;
77 + return true;
78 + }
79 + });
80 + return nameWithExt;
81 + }
82 +
83 + // Recursive
84 + function findImplicitJakefile() {
85 + let cwd = process.cwd();
86 + let names = IMPLICIT_JAKEFILE_NAMES;
87 + let found = null;
88 + names.some((name) => {
89 + let n;
90 + // Prefer all-lowercase
91 + n = name.toLowerCase();
92 + if ((found = fileExists(n))) {
93 + return found;
94 + }
95 + // Check mixed-case as well
96 + n = name;
97 + if ((found = fileExists(n))) {
98 + return found;
99 + }
100 + });
101 + if (found) {
102 + return found;
103 + }
104 + else {
105 + process.chdir("..");
106 + // If we've walked all the way up the directory tree,
107 + // bail out with no result
108 + if (cwd === process.cwd()) {
109 + return null;
110 + }
111 + return findImplicitJakefile();
112 + }
113 + }
114 +
115 + this.loadFile = function (fileSpecified) {
116 + let jakefile;
117 + let origCwd = process.cwd();
118 +
119 + if (fileSpecified) {
120 + if (existsSync(fileSpecified)) {
121 + jakefile = fileSpecified;
122 + }
123 + }
124 + else {
125 + jakefile = findImplicitJakefile();
126 + }
127 +
128 + if (jakefile) {
129 + let ext = jakefile.split('.')[1];
130 + let loaderFunc = SUPPORTED_EXTENSIONS[ext];
131 + loaderFunc && loaderFunc();
132 +
133 + loadFile(utils.file.absolutize(jakefile));
134 + return true;
135 + }
136 + else {
137 + if (!fileSpecified) {
138 + // Restore the working directory on failure
139 + process.chdir(origCwd);
140 + }
141 + return false;
142 + }
143 + };
144 +
145 + this.loadDirectory = function (d) {
146 + let dirname = d || 'jakelib';
147 + let dirlist;
148 + dirname = utils.file.absolutize(dirname);
149 + if (existsSync(dirname)) {
150 + dirlist = fs.readdirSync(dirname);
151 + dirlist.forEach(function (filePath) {
152 + if (JAKELIB_FILE_PAT.test(filePath)) {
153 + loadFile(path.join(dirname, filePath));
154 + }
155 + });
156 + return true;
157 + }
158 + return false;
159 + };
160 +
161 +};
162 +
163 +module.exports = function () {
164 + return new Loader();
165 +};
1 +const ROOT_NAMESPACE_NAME = '__rootNamespace__';
2 +
3 +class Namespace {
4 + constructor(name, parentNamespace) {
5 + this.name = name;
6 + this.parentNamespace = parentNamespace;
7 + this.childNamespaces = {};
8 + this.tasks = {};
9 + this.rules = {};
10 + this.path = this.getPath();
11 + }
12 +
13 + get fullName() {
14 + return this._getFullName();
15 + }
16 +
17 + addTask(task) {
18 + this.tasks[task.name] = task;
19 + task.namespace = this;
20 + }
21 +
22 + resolveTask(name) {
23 + if (!name) {
24 + return;
25 + }
26 +
27 + let taskPath = name.split(':');
28 + let taskName = taskPath.pop();
29 + let task;
30 + let ns;
31 +
32 + // Namespaced, return either relative to current, or from root
33 + if (taskPath.length) {
34 + taskPath = taskPath.join(':');
35 + ns = this.resolveNamespace(taskPath) ||
36 + Namespace.ROOT_NAMESPACE.resolveNamespace(taskPath);
37 + task = (ns && ns.resolveTask(taskName));
38 + }
39 + // Bare task, return either local, or top-level
40 + else {
41 + task = this.tasks[name] || Namespace.ROOT_NAMESPACE.tasks[name];
42 + }
43 +
44 + return task || null;
45 + }
46 +
47 +
48 + resolveNamespace(relativeName) {
49 + if (!relativeName) {
50 + return this;
51 + }
52 +
53 + let parts = relativeName.split(':');
54 + let ns = this;
55 +
56 + for (let i = 0, ii = parts.length; (ns && i < ii); i++) {
57 + ns = ns.childNamespaces[parts[i]];
58 + }
59 +
60 + return ns || null;
61 + }
62 +
63 + matchRule(relativeName) {
64 + let parts = relativeName.split(':');
65 + parts.pop();
66 + let ns = this.resolveNamespace(parts.join(':'));
67 + let rules = ns ? ns.rules : [];
68 + let r;
69 + let match;
70 +
71 + for (let p in rules) {
72 + r = rules[p];
73 + if (r.match(relativeName)) {
74 + match = r;
75 + }
76 + }
77 +
78 + return (ns && match) ||
79 + (this.parentNamespace &&
80 + this.parentNamespace.matchRule(relativeName));
81 + }
82 +
83 + getPath() {
84 + let parts = [];
85 + let next = this.parentNamespace;
86 + while (next) {
87 + parts.push(next.name);
88 + next = next.parentNamespace;
89 + }
90 + parts.pop(); // Remove '__rootNamespace__'
91 + return parts.reverse().join(':');
92 + }
93 +
94 + _getFullName() {
95 + let path = this.path;
96 + path = (path && path.split(':')) || [];
97 + path.push(this.name);
98 + return path.join(':');
99 + }
100 +
101 + isRootNamespace() {
102 + return !this.parentNamespace;
103 + }
104 +}
105 +
106 +class RootNamespace extends Namespace {
107 + constructor() {
108 + super(ROOT_NAMESPACE_NAME, null);
109 + Namespace.ROOT_NAMESPACE = this;
110 + }
111 +}
112 +
113 +module.exports.Namespace = Namespace;
114 +module.exports.RootNamespace = RootNamespace;
115 +
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.