serverless-spy 0.0.41 → 0.0.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/.jsii +2 -3
  2. package/cli/cli.ts +53 -12
  3. package/cli/package.json +1 -4
  4. package/dist/releasetag.txt +1 -1
  5. package/lib/cli/cli.js +37 -13
  6. package/lib/cli/cli.mjs +37 -13
  7. package/lib/cli/cli.ts +53 -12
  8. package/lib/cli/package.json +1 -4
  9. package/lib/src/ServerlessSpy.js +1 -1
  10. package/package.json +1 -3
  11. package/node_modules/expand-tilde/LICENSE +0 -21
  12. package/node_modules/expand-tilde/README.md +0 -80
  13. package/node_modules/expand-tilde/index.js +0 -22
  14. package/node_modules/expand-tilde/package.json +0 -67
  15. package/node_modules/get-installed-path/CHANGELOG.md +0 -99
  16. package/node_modules/get-installed-path/LICENSE +0 -21
  17. package/node_modules/get-installed-path/README.md +0 -282
  18. package/node_modules/get-installed-path/dist/index.es.js +0 -181
  19. package/node_modules/get-installed-path/dist/index.js +0 -188
  20. package/node_modules/get-installed-path/package.json +0 -101
  21. package/node_modules/global-modules/LICENSE +0 -21
  22. package/node_modules/global-modules/README.md +0 -75
  23. package/node_modules/global-modules/index.js +0 -31
  24. package/node_modules/global-modules/package.json +0 -72
  25. package/node_modules/global-prefix/LICENSE +0 -21
  26. package/node_modules/global-prefix/README.md +0 -78
  27. package/node_modules/global-prefix/index.js +0 -96
  28. package/node_modules/global-prefix/node_modules/which/CHANGELOG.md +0 -152
  29. package/node_modules/global-prefix/node_modules/which/LICENSE +0 -15
  30. package/node_modules/global-prefix/node_modules/which/README.md +0 -51
  31. package/node_modules/global-prefix/node_modules/which/bin/which +0 -52
  32. package/node_modules/global-prefix/node_modules/which/package.json +0 -30
  33. package/node_modules/global-prefix/node_modules/which/which.js +0 -135
  34. package/node_modules/global-prefix/package.json +0 -75
  35. package/node_modules/homedir-polyfill/LICENSE +0 -21
  36. package/node_modules/homedir-polyfill/README.md +0 -96
  37. package/node_modules/homedir-polyfill/index.js +0 -9
  38. package/node_modules/homedir-polyfill/package.json +0 -62
  39. package/node_modules/homedir-polyfill/polyfill.js +0 -81
  40. package/node_modules/ini/LICENSE +0 -15
  41. package/node_modules/ini/README.md +0 -102
  42. package/node_modules/ini/ini.js +0 -206
  43. package/node_modules/ini/package.json +0 -33
  44. package/node_modules/is-windows/LICENSE +0 -21
  45. package/node_modules/is-windows/README.md +0 -95
  46. package/node_modules/is-windows/index.js +0 -27
  47. package/node_modules/is-windows/package.json +0 -71
  48. package/node_modules/isexe/.npmignore +0 -2
  49. package/node_modules/isexe/LICENSE +0 -15
  50. package/node_modules/isexe/README.md +0 -51
  51. package/node_modules/isexe/index.js +0 -57
  52. package/node_modules/isexe/mode.js +0 -41
  53. package/node_modules/isexe/package.json +0 -31
  54. package/node_modules/isexe/test/basic.js +0 -221
  55. package/node_modules/isexe/windows.js +0 -42
  56. package/node_modules/parse-passwd/LICENSE +0 -21
  57. package/node_modules/parse-passwd/README.md +0 -86
  58. package/node_modules/parse-passwd/index.js +0 -56
  59. package/node_modules/parse-passwd/package.json +0 -55
  60. package/node_modules/resolve-dir/LICENSE +0 -21
  61. package/node_modules/resolve-dir/README.md +0 -88
  62. package/node_modules/resolve-dir/index.js +0 -22
  63. package/node_modules/resolve-dir/package.json +0 -73
@@ -1,41 +0,0 @@
1
- module.exports = isexe
2
- isexe.sync = sync
3
-
4
- var fs = require('fs')
5
-
6
- function isexe (path, options, cb) {
7
- fs.stat(path, function (er, stat) {
8
- cb(er, er ? false : checkStat(stat, options))
9
- })
10
- }
11
-
12
- function sync (path, options) {
13
- return checkStat(fs.statSync(path), options)
14
- }
15
-
16
- function checkStat (stat, options) {
17
- return stat.isFile() && checkMode(stat, options)
18
- }
19
-
20
- function checkMode (stat, options) {
21
- var mod = stat.mode
22
- var uid = stat.uid
23
- var gid = stat.gid
24
-
25
- var myUid = options.uid !== undefined ?
26
- options.uid : process.getuid && process.getuid()
27
- var myGid = options.gid !== undefined ?
28
- options.gid : process.getgid && process.getgid()
29
-
30
- var u = parseInt('100', 8)
31
- var g = parseInt('010', 8)
32
- var o = parseInt('001', 8)
33
- var ug = u | g
34
-
35
- var ret = (mod & o) ||
36
- (mod & g) && gid === myGid ||
37
- (mod & u) && uid === myUid ||
38
- (mod & ug) && myUid === 0
39
-
40
- return ret
41
- }
@@ -1,31 +0,0 @@
1
- {
2
- "name": "isexe",
3
- "version": "2.0.0",
4
- "description": "Minimal module to check if a file is executable.",
5
- "main": "index.js",
6
- "directories": {
7
- "test": "test"
8
- },
9
- "devDependencies": {
10
- "mkdirp": "^0.5.1",
11
- "rimraf": "^2.5.0",
12
- "tap": "^10.3.0"
13
- },
14
- "scripts": {
15
- "test": "tap test/*.js --100",
16
- "preversion": "npm test",
17
- "postversion": "npm publish",
18
- "postpublish": "git push origin --all; git push origin --tags"
19
- },
20
- "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
21
- "license": "ISC",
22
- "repository": {
23
- "type": "git",
24
- "url": "git+https://github.com/isaacs/isexe.git"
25
- },
26
- "keywords": [],
27
- "bugs": {
28
- "url": "https://github.com/isaacs/isexe/issues"
29
- },
30
- "homepage": "https://github.com/isaacs/isexe#readme"
31
- }
@@ -1,221 +0,0 @@
1
- var t = require('tap')
2
- var fs = require('fs')
3
- var path = require('path')
4
- var fixture = path.resolve(__dirname, 'fixtures')
5
- var meow = fixture + '/meow.cat'
6
- var mine = fixture + '/mine.cat'
7
- var ours = fixture + '/ours.cat'
8
- var fail = fixture + '/fail.false'
9
- var noent = fixture + '/enoent.exe'
10
- var mkdirp = require('mkdirp')
11
- var rimraf = require('rimraf')
12
-
13
- var isWindows = process.platform === 'win32'
14
- var hasAccess = typeof fs.access === 'function'
15
- var winSkip = isWindows && 'windows'
16
- var accessSkip = !hasAccess && 'no fs.access function'
17
- var hasPromise = typeof Promise === 'function'
18
- var promiseSkip = !hasPromise && 'no global Promise'
19
-
20
- function reset () {
21
- delete require.cache[require.resolve('../')]
22
- return require('../')
23
- }
24
-
25
- t.test('setup fixtures', function (t) {
26
- rimraf.sync(fixture)
27
- mkdirp.sync(fixture)
28
- fs.writeFileSync(meow, '#!/usr/bin/env cat\nmeow\n')
29
- fs.chmodSync(meow, parseInt('0755', 8))
30
- fs.writeFileSync(fail, '#!/usr/bin/env false\n')
31
- fs.chmodSync(fail, parseInt('0644', 8))
32
- fs.writeFileSync(mine, '#!/usr/bin/env cat\nmine\n')
33
- fs.chmodSync(mine, parseInt('0744', 8))
34
- fs.writeFileSync(ours, '#!/usr/bin/env cat\nours\n')
35
- fs.chmodSync(ours, parseInt('0754', 8))
36
- t.end()
37
- })
38
-
39
- t.test('promise', { skip: promiseSkip }, function (t) {
40
- var isexe = reset()
41
- t.test('meow async', function (t) {
42
- isexe(meow).then(function (is) {
43
- t.ok(is)
44
- t.end()
45
- })
46
- })
47
- t.test('fail async', function (t) {
48
- isexe(fail).then(function (is) {
49
- t.notOk(is)
50
- t.end()
51
- })
52
- })
53
- t.test('noent async', function (t) {
54
- isexe(noent).catch(function (er) {
55
- t.ok(er)
56
- t.end()
57
- })
58
- })
59
- t.test('noent ignore async', function (t) {
60
- isexe(noent, { ignoreErrors: true }).then(function (is) {
61
- t.notOk(is)
62
- t.end()
63
- })
64
- })
65
- t.end()
66
- })
67
-
68
- t.test('no promise', function (t) {
69
- global.Promise = null
70
- var isexe = reset()
71
- t.throws('try to meow a promise', function () {
72
- isexe(meow)
73
- })
74
- t.end()
75
- })
76
-
77
- t.test('access', { skip: accessSkip || winSkip }, function (t) {
78
- runTest(t)
79
- })
80
-
81
- t.test('mode', { skip: winSkip }, function (t) {
82
- delete fs.access
83
- delete fs.accessSync
84
- var isexe = reset()
85
- t.ok(isexe.sync(ours, { uid: 0, gid: 0 }))
86
- t.ok(isexe.sync(mine, { uid: 0, gid: 0 }))
87
- runTest(t)
88
- })
89
-
90
- t.test('windows', function (t) {
91
- global.TESTING_WINDOWS = true
92
- var pathExt = '.EXE;.CAT;.CMD;.COM'
93
- t.test('pathExt option', function (t) {
94
- runTest(t, { pathExt: '.EXE;.CAT;.CMD;.COM' })
95
- })
96
- t.test('pathExt env', function (t) {
97
- process.env.PATHEXT = pathExt
98
- runTest(t)
99
- })
100
- t.test('no pathExt', function (t) {
101
- // with a pathExt of '', any filename is fine.
102
- // so the "fail" one would still pass.
103
- runTest(t, { pathExt: '', skipFail: true })
104
- })
105
- t.test('pathext with empty entry', function (t) {
106
- // with a pathExt of '', any filename is fine.
107
- // so the "fail" one would still pass.
108
- runTest(t, { pathExt: ';' + pathExt, skipFail: true })
109
- })
110
- t.end()
111
- })
112
-
113
- t.test('cleanup', function (t) {
114
- rimraf.sync(fixture)
115
- t.end()
116
- })
117
-
118
- function runTest (t, options) {
119
- var isexe = reset()
120
-
121
- var optionsIgnore = Object.create(options || {})
122
- optionsIgnore.ignoreErrors = true
123
-
124
- if (!options || !options.skipFail) {
125
- t.notOk(isexe.sync(fail, options))
126
- }
127
- t.notOk(isexe.sync(noent, optionsIgnore))
128
- if (!options) {
129
- t.ok(isexe.sync(meow))
130
- } else {
131
- t.ok(isexe.sync(meow, options))
132
- }
133
-
134
- t.ok(isexe.sync(mine, options))
135
- t.ok(isexe.sync(ours, options))
136
- t.throws(function () {
137
- isexe.sync(noent, options)
138
- })
139
-
140
- t.test('meow async', function (t) {
141
- if (!options) {
142
- isexe(meow, function (er, is) {
143
- if (er) {
144
- throw er
145
- }
146
- t.ok(is)
147
- t.end()
148
- })
149
- } else {
150
- isexe(meow, options, function (er, is) {
151
- if (er) {
152
- throw er
153
- }
154
- t.ok(is)
155
- t.end()
156
- })
157
- }
158
- })
159
-
160
- t.test('mine async', function (t) {
161
- isexe(mine, options, function (er, is) {
162
- if (er) {
163
- throw er
164
- }
165
- t.ok(is)
166
- t.end()
167
- })
168
- })
169
-
170
- t.test('ours async', function (t) {
171
- isexe(ours, options, function (er, is) {
172
- if (er) {
173
- throw er
174
- }
175
- t.ok(is)
176
- t.end()
177
- })
178
- })
179
-
180
- if (!options || !options.skipFail) {
181
- t.test('fail async', function (t) {
182
- isexe(fail, options, function (er, is) {
183
- if (er) {
184
- throw er
185
- }
186
- t.notOk(is)
187
- t.end()
188
- })
189
- })
190
- }
191
-
192
- t.test('noent async', function (t) {
193
- isexe(noent, options, function (er, is) {
194
- t.ok(er)
195
- t.notOk(is)
196
- t.end()
197
- })
198
- })
199
-
200
- t.test('noent ignore async', function (t) {
201
- isexe(noent, optionsIgnore, function (er, is) {
202
- if (er) {
203
- throw er
204
- }
205
- t.notOk(is)
206
- t.end()
207
- })
208
- })
209
-
210
- t.test('directory is not executable', function (t) {
211
- isexe(__dirname, options, function (er, is) {
212
- if (er) {
213
- throw er
214
- }
215
- t.notOk(is)
216
- t.end()
217
- })
218
- })
219
-
220
- t.end()
221
- }
@@ -1,42 +0,0 @@
1
- module.exports = isexe
2
- isexe.sync = sync
3
-
4
- var fs = require('fs')
5
-
6
- function checkPathExt (path, options) {
7
- var pathext = options.pathExt !== undefined ?
8
- options.pathExt : process.env.PATHEXT
9
-
10
- if (!pathext) {
11
- return true
12
- }
13
-
14
- pathext = pathext.split(';')
15
- if (pathext.indexOf('') !== -1) {
16
- return true
17
- }
18
- for (var i = 0; i < pathext.length; i++) {
19
- var p = pathext[i].toLowerCase()
20
- if (p && path.substr(-p.length).toLowerCase() === p) {
21
- return true
22
- }
23
- }
24
- return false
25
- }
26
-
27
- function checkStat (stat, path, options) {
28
- if (!stat.isSymbolicLink() && !stat.isFile()) {
29
- return false
30
- }
31
- return checkPathExt(path, options)
32
- }
33
-
34
- function isexe (path, options, cb) {
35
- fs.stat(path, function (er, stat) {
36
- cb(er, er ? false : checkStat(stat, path, options))
37
- })
38
- }
39
-
40
- function sync (path, options) {
41
- return checkStat(fs.statSync(path), path, options)
42
- }
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2016 Brian Woodward
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,86 +0,0 @@
1
- # parse-passwd [![NPM version](https://img.shields.io/npm/v/parse-passwd.svg?style=flat)](https://www.npmjs.com/package/parse-passwd) [![NPM downloads](https://img.shields.io/npm/dm/parse-passwd.svg?style=flat)](https://npmjs.org/package/parse-passwd) [![Linux Build Status](https://img.shields.io/travis/doowb/parse-passwd.svg?style=flat&label=Travis)](https://travis-ci.org/doowb/parse-passwd) [![Windows Build Status](https://img.shields.io/appveyor/ci/doowb/parse-passwd.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/doowb/parse-passwd)
2
-
3
- > Parse a passwd file into a list of users.
4
-
5
- ## Install
6
-
7
- Install with [npm](https://www.npmjs.com/):
8
-
9
- ```sh
10
- $ npm install --save parse-passwd
11
- ```
12
-
13
- ## Usage
14
-
15
- ```js
16
- var parse = require('parse-passwd');
17
- ```
18
-
19
- ## API
20
-
21
- **Example**
22
-
23
- ```js
24
- // assuming '/etc/passwd' contains:
25
- // doowb:*:123:123:Brian Woodward:/Users/doowb:/bin/bash
26
- console.log(parse(fs.readFileSync('/etc/passwd', 'utf8')));
27
-
28
- //=> [
29
- //=> {
30
- //=> username: 'doowb',
31
- //=> password: '*',
32
- //=> uid: '123',
33
- //=> gid: '123',
34
- //=> gecos: 'Brian Woodward',
35
- //=> homedir: '/Users/doowb',
36
- //=> shell: '/bin/bash'
37
- //=> }
38
- //=> ]
39
- ```
40
-
41
- **Params**
42
-
43
- * `content` **{String}**: Content of a passwd file to parse.
44
- * `returns` **{Array}**: Array of user objects parsed from the content.
45
-
46
- ## About
47
-
48
- ### Contributing
49
-
50
- Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
51
-
52
- Please read the [contributing guide](contributing.md) for avice on opening issues, pull requests, and coding standards.
53
-
54
- ### Building docs
55
-
56
- _(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_
57
-
58
- To generate the readme and API documentation with [verb](https://github.com/verbose/verb):
59
-
60
- ```sh
61
- $ npm install -g verb verb-generate-readme && verb
62
- ```
63
-
64
- ### Running tests
65
-
66
- Install dev dependencies:
67
-
68
- ```sh
69
- $ npm install -d && npm test
70
- ```
71
-
72
- ### Author
73
-
74
- **Brian Woodward**
75
-
76
- * [github/doowb](https://github.com/doowb)
77
- * [twitter/doowb](http://twitter.com/doowb)
78
-
79
- ### License
80
-
81
- Copyright © 2016, [Brian Woodward](https://github.com/doowb).
82
- Released under the [MIT license](LICENSE).
83
-
84
- ***
85
-
86
- _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.2.0, on October 19, 2016._
@@ -1,56 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Parse the content of a passwd file into a list of user objects.
5
- * This function ignores blank lines and comments.
6
- *
7
- * ```js
8
- * // assuming '/etc/passwd' contains:
9
- * // doowb:*:123:123:Brian Woodward:/Users/doowb:/bin/bash
10
- * console.log(parse(fs.readFileSync('/etc/passwd', 'utf8')));
11
- *
12
- * //=> [
13
- * //=> {
14
- * //=> username: 'doowb',
15
- * //=> password: '*',
16
- * //=> uid: '123',
17
- * //=> gid: '123',
18
- * //=> gecos: 'Brian Woodward',
19
- * //=> homedir: '/Users/doowb',
20
- * //=> shell: '/bin/bash'
21
- * //=> }
22
- * //=> ]
23
- * ```
24
- * @param {String} `content` Content of a passwd file to parse.
25
- * @return {Array} Array of user objects parsed from the content.
26
- * @api public
27
- */
28
-
29
- module.exports = function(content) {
30
- if (typeof content !== 'string') {
31
- throw new Error('expected a string');
32
- }
33
- return content
34
- .split('\n')
35
- .map(user)
36
- .filter(Boolean);
37
- };
38
-
39
- function user(line, i) {
40
- if (!line || !line.length || line.charAt(0) === '#') {
41
- return null;
42
- }
43
-
44
- // see https://en.wikipedia.org/wiki/Passwd for field descriptions
45
- var fields = line.split(':');
46
- return {
47
- username: fields[0],
48
- password: fields[1],
49
- uid: fields[2],
50
- gid: fields[3],
51
- // see https://en.wikipedia.org/wiki/Gecos_field for GECOS field descriptions
52
- gecos: fields[4],
53
- homedir: fields[5],
54
- shell: fields[6]
55
- };
56
- }
@@ -1,55 +0,0 @@
1
- {
2
- "name": "parse-passwd",
3
- "description": "Parse a passwd file into a list of users.",
4
- "version": "1.0.0",
5
- "homepage": "https://github.com/doowb/parse-passwd",
6
- "author": "Brian Woodward (https://github.com/doowb)",
7
- "repository": "doowb/parse-passwd",
8
- "bugs": {
9
- "url": "https://github.com/doowb/parse-passwd/issues"
10
- },
11
- "license": "MIT",
12
- "files": [
13
- "index.js",
14
- "LICENSE"
15
- ],
16
- "main": "index.js",
17
- "engines": {
18
- "node": ">=0.10.0"
19
- },
20
- "scripts": {
21
- "test": "mocha"
22
- },
23
- "devDependencies": {
24
- "gulp-format-md": "^0.1.11",
25
- "mocha": "^3.1.2"
26
- },
27
- "keywords": [
28
- "etc",
29
- "etc-passwd",
30
- "etc/passwd",
31
- "parse",
32
- "parse-passwd",
33
- "passwd"
34
- ],
35
- "verb": {
36
- "toc": false,
37
- "layout": "default",
38
- "tasks": [
39
- "readme"
40
- ],
41
- "plugins": [
42
- "gulp-format-md"
43
- ],
44
- "lint": {
45
- "reflinks": true
46
- },
47
- "related": {
48
- "list": []
49
- },
50
- "reflinks": [
51
- "verb",
52
- "verb-generate-readme"
53
- ]
54
- }
55
- }
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2015-2016, Jon Schlinkert
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,88 +0,0 @@
1
- # resolve-dir [![NPM version](https://img.shields.io/npm/v/resolve-dir.svg?style=flat)](https://www.npmjs.com/package/resolve-dir) [![NPM downloads](https://img.shields.io/npm/dm/resolve-dir.svg?style=flat)](https://npmjs.org/package/resolve-dir) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/resolve-dir.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/resolve-dir)
2
-
3
- > Resolve a directory that is either local, global or in the user's home directory.
4
-
5
- ## Install
6
-
7
- Install with [npm](https://www.npmjs.com/):
8
-
9
- ```sh
10
- $ npm install --save resolve-dir
11
- ```
12
-
13
- ## Usage
14
-
15
- ```js
16
- var resolve = require('resolve-dir');
17
- ```
18
-
19
- Returns a local directory path unchanged
20
-
21
- ```js
22
- resolve('a')
23
- //=> 'a'
24
- ```
25
-
26
- Resolves the path to user home
27
-
28
- ```js
29
- resolve('~')
30
- //=> '/Users/jonschlinkert'
31
- resolve('~/foo')
32
- //=> '/Users/jonschlinkert/foo'
33
- ```
34
-
35
- Resolves the path to global npm modules
36
-
37
- ```js
38
- resolve('@')
39
- //=> '/usr/local/lib/node_modules'
40
- resolve('@/foo')
41
- //=> '/usr/local/lib/node_modules/foo'
42
- ```
43
-
44
- ## About
45
-
46
- ### Related projects
47
-
48
- * [expand-tilde](https://www.npmjs.com/package/expand-tilde): Bash-like tilde expansion for node.js. Expands a leading tilde in a file path to the… [more](https://github.com/jonschlinkert/expand-tilde) | [homepage](https://github.com/jonschlinkert/expand-tilde "Bash-like tilde expansion for node.js. Expands a leading tilde in a file path to the user home directory, or `~+` to the cwd.")
49
- * [findup-sync](https://www.npmjs.com/package/findup-sync): Find the first file matching a given pattern in the current directory or the nearest… [more](https://github.com/cowboy/node-findup-sync) | [homepage](https://github.com/cowboy/node-findup-sync "Find the first file matching a given pattern in the current directory or the nearest ancestor directory.")
50
- * [resolve-modules](https://www.npmjs.com/package/resolve-modules): Resolves local and global npm modules that match specified patterns, and returns a configuration object… [more](https://github.com/jonschlinkert/resolve-modules) | [homepage](https://github.com/jonschlinkert/resolve-modules "Resolves local and global npm modules that match specified patterns, and returns a configuration object for each resolved module.")
51
-
52
- ### Contributing
53
-
54
- Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
55
-
56
- ### Building docs
57
-
58
- _(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_
59
-
60
- To generate the readme and API documentation with [verb](https://github.com/verbose/verb):
61
-
62
- ```sh
63
- $ npm install -g verb verb-generate-readme && verb
64
- ```
65
-
66
- ### Running tests
67
-
68
- Install dev dependencies:
69
-
70
- ```sh
71
- $ npm install -d && npm test
72
- ```
73
-
74
- ### Author
75
-
76
- **Jon Schlinkert**
77
-
78
- * [github/jonschlinkert](https://github.com/jonschlinkert)
79
- * [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
80
-
81
- ### License
82
-
83
- Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
84
- Released under the [MIT license](https://github.com/jonschlinkert/resolve-dir/blob/master/LICENSE).
85
-
86
- ***
87
-
88
- _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.2.0, on October 18, 2016._
@@ -1,22 +0,0 @@
1
- /*!
2
- * resolve-dir <https://github.com/jonschlinkert/resolve-dir>
3
- *
4
- * Copyright (c) 2015, Jon Schlinkert.
5
- * Licensed under the MIT License.
6
- */
7
-
8
- 'use strict';
9
-
10
- var path = require('path');
11
- var expand = require('expand-tilde');
12
- var gm = require('global-modules');
13
-
14
- module.exports = function resolveDir(dir) {
15
- if (dir.charAt(0) === '~') {
16
- dir = expand(dir);
17
- }
18
- if (dir.charAt(0) === '@') {
19
- dir = path.join(gm, dir.slice(1));
20
- }
21
- return dir;
22
- };