init
This commit is contained in:
4
node_modules/parents/.travis.yml
generated
vendored
Normal file
4
node_modules/parents/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.6
|
||||
- 0.8
|
18
node_modules/parents/LICENSE
generated
vendored
Normal file
18
node_modules/parents/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
This software is released under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
3
node_modules/parents/example/dirname.js
generated
vendored
Normal file
3
node_modules/parents/example/dirname.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
var parents = require('../');
|
||||
var dirs = parents(__dirname);
|
||||
console.dir(dirs);
|
5
node_modules/parents/example/win32.js
generated
vendored
Normal file
5
node_modules/parents/example/win32.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
var parents = require('../');
|
||||
var dir = 'C:\\Program Files\\Maxis\\Sim City 2000\\cities';
|
||||
|
||||
var dirs = parents(dir, { platform : 'win32' });
|
||||
console.dir(dirs);
|
48
node_modules/parents/index.js
generated
vendored
Normal file
48
node_modules/parents/index.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
var pathPlatform = require('path-platform');
|
||||
|
||||
module.exports = function (cwd, opts) {
|
||||
if (cwd === undefined) cwd = process.cwd();
|
||||
if (!opts) opts = {};
|
||||
var platform = opts.platform || process.platform;
|
||||
|
||||
var isWindows = /^win/.test(platform);
|
||||
var path = isWindows ? pathPlatform.win32 : pathPlatform;
|
||||
var normalize = !isWindows ? path.normalize :
|
||||
path.normalize('c:') === 'c:.' ? fixNormalize(path.normalize) :
|
||||
path.normalize;
|
||||
var sep = isWindows ? /[\\\/]/ : '/';
|
||||
var init = isWindows ? '' : '/';
|
||||
|
||||
var join = function (x, y) {
|
||||
var ps = [ x, y ].filter(function (p) {
|
||||
return p && typeof p === 'string'
|
||||
});
|
||||
|
||||
return normalize(ps.join(isWindows ? '\\' : '/'));
|
||||
};
|
||||
|
||||
var res = normalize(cwd)
|
||||
.split(sep)
|
||||
.reduce(function (acc,dir,ix) {
|
||||
return acc.concat(join(acc[ix], dir))
|
||||
}, [init])
|
||||
.slice(1)
|
||||
.reverse()
|
||||
;
|
||||
if (res[0] === res[1]) return [ res[0] ];
|
||||
if (isWindows && /^\\/.test(cwd)) {
|
||||
return res.slice(0,-1).map(function (d) {
|
||||
var ch = d.charAt(0)
|
||||
return ch === '\\' ? d :
|
||||
ch === '.' ? '\\' + d.slice(1) :
|
||||
'\\' + d
|
||||
});
|
||||
}
|
||||
return res;
|
||||
|
||||
function fixNormalize(fn) {
|
||||
return function(p) {
|
||||
return fn(p).replace(/:\.$/, ':')
|
||||
}
|
||||
}
|
||||
}
|
38
node_modules/parents/package.json
generated
vendored
Normal file
38
node_modules/parents/package.json
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name" : "parents",
|
||||
"version" : "1.0.1",
|
||||
"description" : "return all the parent directories for a directory",
|
||||
"main" : "index.js",
|
||||
"bin" : {},
|
||||
"directories" : {
|
||||
"example" : "example",
|
||||
"test" : "test"
|
||||
},
|
||||
"dependencies" : {
|
||||
"path-platform": "~0.11.15"
|
||||
},
|
||||
"devDependencies" : {
|
||||
"tap" : "~0.2.5"
|
||||
},
|
||||
"scripts" : {
|
||||
"test" : "tap test/*.js"
|
||||
},
|
||||
"repository" : {
|
||||
"type" : "git",
|
||||
"url" : "git://github.com/substack/node-parents.git"
|
||||
},
|
||||
"homepage" : "https://github.com/substack/node-parents",
|
||||
"keywords" : [
|
||||
"directory",
|
||||
"parent",
|
||||
"path",
|
||||
"tree"
|
||||
],
|
||||
"author" : {
|
||||
"name" : "James Halliday",
|
||||
"email" : "mail@substack.net",
|
||||
"url" : "http://substack.net"
|
||||
},
|
||||
"license" : "MIT",
|
||||
"engine" : { "node" : ">=0.6" }
|
||||
}
|
75
node_modules/parents/readme.markdown
generated
vendored
Normal file
75
node_modules/parents/readme.markdown
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
# parents
|
||||
|
||||
Return all the parent directories of a directory, inclusive of that directory.
|
||||
|
||||
[](http://travis-ci.org/substack/node-parents)
|
||||
|
||||
# example
|
||||
|
||||
## dirname
|
||||
|
||||
``` js
|
||||
var parents = require('parents');
|
||||
var dirs = parents(__dirname);
|
||||
console.dir(dirs);
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
```
|
||||
[ '/home/substack/projects/node-parents/example',
|
||||
'/home/substack/projects/node-parents',
|
||||
'/home/substack/projects',
|
||||
'/home/substack',
|
||||
'/home',
|
||||
'/' ]
|
||||
```
|
||||
|
||||
## win32
|
||||
|
||||
``` js
|
||||
var parents = require('parents');
|
||||
var dir = 'C:\\Program Files\\Maxis\\Sim City 2000\\cities';
|
||||
|
||||
var dirs = parents(dir, { platform : 'win32' });
|
||||
console.dir(dirs);
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
```
|
||||
[ 'C:\\Program Files\\Maxis\\Sim City 2000\\cities',
|
||||
'C:\\Program Files\\Maxis\\Sim City 2000',
|
||||
'C:\\Program Files\\Maxis',
|
||||
'C:\\Program Files',
|
||||
'C:' ]
|
||||
```
|
||||
|
||||
# methods
|
||||
|
||||
``` js
|
||||
var parents = require('parents')
|
||||
```
|
||||
|
||||
## parents(dir, opts)
|
||||
|
||||
Return an array of the parent directories of `dir`, including and starting with
|
||||
`dir`. If a `dir` isn't specified, `process.cwd()` will be used.
|
||||
|
||||
Optionally specify an `opts.platform` to control whether the separator and paths
|
||||
works the unixy way with `'/'` or the windowsy way where sometimes things use
|
||||
`'/'` and sometimes they use `'\\'` and also there are leading drive letters and
|
||||
other exotic features. If `opts.platform` isn't specified, `process.platform`
|
||||
will be used. Anything that matches `/^win/` will use the windowsy behavior.
|
||||
|
||||
# install
|
||||
|
||||
With [npm](http://npmjs.org) do:
|
||||
|
||||
```
|
||||
npm install parents
|
||||
```
|
||||
|
||||
# licence
|
||||
|
||||
MIT
|
20
node_modules/parents/test/dirname.js
generated
vendored
Normal file
20
node_modules/parents/test/dirname.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
var test = require('tap').test;
|
||||
var parents = require('../');
|
||||
|
||||
test('dirname', function (t) {
|
||||
var dirs = parents('/foo/bar/baz/quux');
|
||||
t.same(dirs, [
|
||||
'/foo/bar/baz/quux',
|
||||
'/foo/bar/baz',
|
||||
'/foo/bar',
|
||||
'/foo',
|
||||
'/',
|
||||
]);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('root', function (t) {
|
||||
var dirs = parents('/');
|
||||
t.same(dirs, [ '/' ]);
|
||||
t.end();
|
||||
});
|
34
node_modules/parents/test/win32.js
generated
vendored
Normal file
34
node_modules/parents/test/win32.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
var test = require('tap').test;
|
||||
var parents = require('../');
|
||||
|
||||
test('win32', function (t) {
|
||||
var dir = 'c:\\Program Files\\Maxis\\Sim City 2000\\cities';
|
||||
var dirs = parents(dir, { platform : 'win32' });
|
||||
t.same(dirs, [
|
||||
'c:\\Program Files\\Maxis\\Sim City 2000\\cities',
|
||||
'c:\\Program Files\\Maxis\\Sim City 2000',
|
||||
'c:\\Program Files\\Maxis',
|
||||
'c:\\Program Files',
|
||||
'c:',
|
||||
]);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('win32 c:', function (t) {
|
||||
var dirs = parents('c:\\', { platform : 'win32' });
|
||||
t.same(dirs, [ 'c:' ]);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('win32 network drive', function (t) {
|
||||
var dirs = parents(
|
||||
'\\storageserver01\\Active Projects\\ProjectA',
|
||||
{ platform : 'win32' }
|
||||
);
|
||||
t.same(dirs, [
|
||||
'\\storageserver01\\Active Projects\\ProjectA',
|
||||
'\\storageserver01\\Active Projects',
|
||||
'\\storageserver01'
|
||||
]);
|
||||
t.end();
|
||||
});
|
Reference in New Issue
Block a user