[Pkg-javascript-commits] [node-glob-parent] 01/06: Import Upstream version 3.0.0
Sruthi Chandran
srud-guest at moszumanska.debian.org
Tue Oct 18 09:47:52 UTC 2016
This is an automated email from the git hooks/post-receive script.
srud-guest pushed a commit to branch master
in repository node-glob-parent.
commit 2413242d58cd3089fb1d00193dd3482030dd8141
Author: Sruthi <srud at disroot.org>
Date: Tue Oct 18 15:00:55 2016 +0530
Import Upstream version 3.0.0
---
.gitignore | 4 ++++
.travis.yml | 8 ++++++++
LICENSE | 15 ++++++++++++++
README.md | 43 +++++++++++++++++++++++++++++++++++++++
index.js | 10 +++++++++
package.json | 35 ++++++++++++++++++++++++++++++++
test.js | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 181 insertions(+)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..33e391f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+node_modules
+.DS_Store
+npm-debug.log
+coverage
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..18fc42f
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,8 @@
+language: node_js
+node_js:
+ - "4"
+ - "iojs-v3"
+ - "iojs-v2"
+ - "iojs-v1"
+ - "0.12"
+ - "0.10"
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..734076d
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,15 @@
+The ISC License
+
+Copyright (c) 2015 Elan Shanker
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..ff5310d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,43 @@
+glob-parent [![Build Status](https://travis-ci.org/es128/glob-parent.svg)](https://travis-ci.org/es128/glob-parent) [![Coverage Status](https://img.shields.io/coveralls/es128/glob-parent.svg)](https://coveralls.io/r/es128/glob-parent?branch=master)
+======
+Javascript module to extract the non-magic parent path from a glob string.
+
+[![NPM](https://nodei.co/npm/glob-parent.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/glob-parent/)
+[![NPM](https://nodei.co/npm-dl/glob-parent.png?height=3&months=9)](https://nodei.co/npm-dl/glob-parent/)
+
+Usage
+-----
+```sh
+npm install glob-parent --save
+```
+
+```js
+var globParent = require('glob-parent');
+
+globParent('path/to/*.js'); // 'path/to'
+globParent('/root/path/to/*.js'); // '/root/path/to'
+globParent('/*.js'); // '/'
+globParent('*.js'); // '.'
+globParent('**/*.js'); // '.'
+globParent('path/{to,from}'); // 'path'
+globParent('path/!(to|from)'); // 'path'
+globParent('path/?(to|from)'); // 'path'
+globParent('path/+(to|from)'); // 'path'
+globParent('path/*(to|from)'); // 'path'
+globParent('path/@(to|from)'); // 'path'
+globParent('path/**/*'); // 'path'
+
+// if provided a non-glob path, returns the nearest dir
+globParent('path/foo/bar.js'); // 'path/foo'
+globParent('path/foo/'); // 'path/foo'
+globParent('path/foo'); // 'path' (see issue #3 for details)
+
+```
+
+Change Log
+----------
+[See release notes page on GitHub](https://github.com/es128/glob-parent/releases)
+
+License
+-------
+[ISC](https://raw.github.com/es128/glob-parent/master/LICENSE)
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..61615f1
--- /dev/null
+++ b/index.js
@@ -0,0 +1,10 @@
+'use strict';
+
+var path = require('path');
+var isglob = require('is-glob');
+
+module.exports = function globParent(str) {
+ str += 'a'; // preserves full path in case of trailing path separator
+ do {str = path.dirname(str)} while (isglob(str));
+ return str;
+};
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..7cb9758
--- /dev/null
+++ b/package.json
@@ -0,0 +1,35 @@
+{
+ "name": "glob-parent",
+ "version": "3.0.0",
+ "description": "Strips glob magic from a string to provide the parent path",
+ "main": "index.js",
+ "scripts": {
+ "test": "istanbul cover _mocha && cat ./coverage/lcov.info | coveralls"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/es128/glob-parent"
+ },
+ "keywords": [
+ "glob",
+ "parent",
+ "strip",
+ "path",
+ "directory",
+ "base"
+ ],
+ "author": "Elan Shanker",
+ "license": "ISC",
+ "bugs": {
+ "url": "https://github.com/es128/glob-parent/issues"
+ },
+ "homepage": "https://github.com/es128/glob-parent",
+ "dependencies": {
+ "is-glob": "^3.0.0"
+ },
+ "devDependencies": {
+ "coveralls": "^2.11.2",
+ "istanbul": "^0.3.5",
+ "mocha": "^2.1.0"
+ }
+}
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..f12a5c8
--- /dev/null
+++ b/test.js
@@ -0,0 +1,66 @@
+'use strict';
+
+var gp = require('./');
+var assert = require('assert');
+
+describe('glob-parent', function() {
+ it('should strip glob magic to return parent path', function() {
+ assert.equal(gp('path/to/*.js'), 'path/to');
+ assert.equal(gp('/root/path/to/*.js'), '/root/path/to');
+ assert.equal(gp('/*.js'), '/');
+ assert.equal(gp('*.js'), '.');
+ assert.equal(gp('**/*.js'), '.');
+ assert.equal(gp('path/{to,from}'), 'path');
+ assert.equal(gp('path/!(to|from)'), 'path');
+ assert.equal(gp('path/?(to|from)'), 'path');
+ assert.equal(gp('path/+(to|from)'), 'path');
+ assert.equal(gp('path/*(to|from)'), 'path');
+ assert.equal(gp('path/@(to|from)'), 'path');
+ assert.equal(gp('path/**/*'), 'path');
+ assert.equal(gp('path/**/subdir/foo.*'), 'path');
+ });
+
+ it('should return parent dirname from non-glob paths', function() {
+ assert.equal(gp('path/foo/bar.js'), 'path/foo');
+ assert.equal(gp('path/foo/'), 'path/foo');
+ assert.equal(gp('path/foo'), 'path');
+ });
+});
+
+describe('glob2base test patterns', function() {
+ it('should get a base name', function() {
+ assert.equal(gp('js/*.js') + '/', 'js/');
+ });
+
+ it('should get a base name from a nested glob', function() {
+ assert.equal(gp('js/**/test/*.js') + '/', 'js/');
+ });
+
+ it('should get a base name from a flat file', function() {
+ assert.equal(gp('js/test/wow.js') + '/', 'js/test/');
+ });
+
+ it('should get a base name from character class pattern', function() {
+ assert.equal(gp('js/t[a-z]st}/*.js') + '/', 'js/');
+ });
+
+ it('should get a base name from brace , expansion', function() {
+ assert.equal(gp('js/{src,test}/*.js') + '/', 'js/');
+ });
+
+ it('should get a base name from brace .. expansion', function() {
+ assert.equal(gp('js/test{0..9}/*.js') + '/', 'js/');
+ });
+
+ it('should get a base name from extglob', function() {
+ assert.equal(gp('js/t+(wo|est)/*.js') + '/', 'js/');
+ });
+
+ it('should get a base name from a complex brace glob', function() {
+ assert.equal(gp('lib/{components,pages}/**/{test,another}/*.txt') + '/', 'lib/');
+
+ assert.equal(gp('js/test/**/{images,components}/*.js') + '/', 'js/test/');
+
+ assert.equal(gp('ooga/{booga,sooga}/**/dooga/{eooga,fooga}') + '/', 'ooga/');
+ });
+});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-glob-parent.git
More information about the Pkg-javascript-commits
mailing list