New Upstream Release - node-to-absolute-glob

Ready changes

Summary

Merged new upstream version: 3.0.0 (was: 2.0.2).

Resulting package

Built on 2023-02-27T01:02 (took 4m29s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-releases node-to-absolute-glob

Lintian Result

Diff

diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..660957e
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,10 @@
+# Enforce Unix newlines
+* text eol=lf
+
+# binaries
+*.ai binary
+*.psd binary
+*.jpg binary
+*.gif binary
+*.png binary
+*.jpeg binary
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..619f53b
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,32 @@
+name: CI
+on:
+  pull_request:
+  push:
+env:
+  CI: true
+
+jobs:
+  test:
+    name: Tests for Node ${{ matrix.node }} on ${{ matrix.os }}
+    runs-on: ${{ matrix.os }}
+
+    strategy:
+      fail-fast: false
+      matrix:
+        node: ["0.12", "4", "5", "6", "8", "10", "12", "14", "16", "18"]
+        os: [ubuntu-latest, windows-latest, macos-latest]
+
+    steps:
+      - name: Clone repository
+        uses: actions/checkout@v3.1.0
+
+      - name: Set Node.js version
+        uses: actions/setup-node@v3.5.1
+        with:
+          node-version: ${{ matrix.node }}
+
+      - name: Install npm dependencies
+        run: npm install
+
+      - name: Run tests
+        run: npm test
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..7988154
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,21 @@
+# always ignore files
+*.DS_Store
+*.sublime-*
+
+# test related, or directories generated by tests
+test/actual
+actual
+coverage
+
+# npm
+node_modules
+npm-debug.log
+
+# misc
+_gh_pages
+benchmark
+bower_components
+vendor
+temp
+tmp
+TODO.md
diff --git a/LICENSE b/LICENSE
index 6525171..9489127 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
 The MIT License (MIT)
 
-Copyright (c) 2015-2016, Jon Schlinkert
+Copyright (c) Jon Schlinkert
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index 59031e1..0000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-# Test against this version of Node.js
-environment:
-  matrix:
-    # node.js
-    - nodejs_version: "6.0"
-    - nodejs_version: "5.0"
-    - nodejs_version: "4.0"
-    - nodejs_version: "0.12"
-    - nodejs_version: "0.10"
-
-# Install scripts. (runs after repo cloning)
-install:
-  # Get the latest stable version of Node.js or io.js
-  - ps: Install-Product node $env:nodejs_version
-  # install modules
-  - npm install
-
-# Post-install test scripts.
-test_script:
-  # Output useful info for debugging.
-  - node --version
-  - npm --version
-  # run tests
-  - npm test
-
-# Don't actually build.
-build: off
diff --git a/debian/changelog b/debian/changelog
index 9e7f0d4..b82c3a6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+node-to-absolute-glob (3.0.0-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Mon, 27 Feb 2023 00:58:41 -0000
+
 node-to-absolute-glob (2.0.2-3) unstable; urgency=medium
 
   [ Debian Janitor ]
diff --git a/debian/patches/use-pathisAbsolute.patch b/debian/patches/use-pathisAbsolute.patch
index 1268cf7..1cdb76c 100644
--- a/debian/patches/use-pathisAbsolute.patch
+++ b/debian/patches/use-pathisAbsolute.patch
@@ -2,8 +2,10 @@ Description: Use pathisAbsolute
  Use path.isabsolute instead of is-absolute
 Forwarded: not-needed
 
---- a/index.js
-+++ b/index.js
+Index: node-to-absolute-glob.git/index.js
+===================================================================
+--- node-to-absolute-glob.git.orig/index.js
++++ node-to-absolute-glob.git/index.js
 @@ -2,7 +2,7 @@
  
  var path = require('path');
diff --git a/examples.js b/examples.js
index bfbe3a0..8dce1ff 100644
--- a/examples.js
+++ b/examples.js
@@ -1,15 +1,15 @@
 
 var toAbsGlob = require('./');
-console.log(toAbsGlob('a'))
-console.log(toAbsGlob('a/*.js'))
-console.log(toAbsGlob('a/*/'))
-console.log(toAbsGlob('./fixtures/whatsgoingon/*/', {cwd: __dirname}))
-console.log(toAbsGlob('!a/*.js'))
-console.log(toAbsGlob('a/*.js', {cwd: 'foo'}))
-console.log(toAbsGlob('!a/*.js', {cwd: 'foo'}))
-console.log(toAbsGlob('/a/*.js', {root: 'baz'}))
-console.log(toAbsGlob('/a/*.js', {root: '/'}))
-console.log(toAbsGlob('!/a/*.js', {root: 'baz'}))
-console.log(toAbsGlob('!/a/*.js', {root: '/'}))
-console.log(toAbsGlob('/\\!/a/*.js', {root: '/'}))
-console.log(toAbsGlob('/\\!\\a/*.js', {root: '/'}))
+console.log(toAbsGlob('a'));
+console.log(toAbsGlob('a/*.js'));
+console.log(toAbsGlob('a/*/'));
+console.log(toAbsGlob('./fixtures/whatsgoingon/*/', {cwd: __dirname}));
+console.log(toAbsGlob('!a/*.js'));
+console.log(toAbsGlob('a/*.js', {cwd: 'foo'}));
+console.log(toAbsGlob('!a/*.js', {cwd: 'foo'}));
+console.log(toAbsGlob('/a/*.js', {root: 'baz'}));
+console.log(toAbsGlob('/a/*.js', {root: '/'}));
+console.log(toAbsGlob('!/a/*.js', {root: 'baz'}));
+console.log(toAbsGlob('!/a/*.js', {root: '/'}));
+console.log(toAbsGlob('/\\!/a/*.js', {root: '/'}));
+console.log(toAbsGlob('/\\!\\a/*.js', {root: '/'}));
diff --git a/index.js b/index.js
index 268fc47..a09536a 100644
--- a/index.js
+++ b/index.js
@@ -9,16 +9,20 @@ module.exports = function(glob, options) {
   var opts = options || {};
 
   // ensure cwd is absolute
-  var cwd = path.resolve(opts.cwd ? opts.cwd : process.cwd());
+  var cwd = unescape(opts.cwd ? opts.cwd : process.cwd());
+  cwd = path.resolve(cwd);
   cwd = unixify(cwd);
+  cwd = escape(cwd);
 
   var rootDir = opts.root;
   // if `options.root` is defined, ensure it's absolute
   if (rootDir) {
+    rootDir = unescape(rootDir);
     rootDir = unixify(rootDir);
     if (process.platform === 'win32' || !isAbsolute(rootDir)) {
       rootDir = unixify(path.resolve(rootDir));
     }
+    rootDir = escape(rootDir);
   }
 
   // trim starting ./ from glob patterns
@@ -54,6 +58,16 @@ module.exports = function(glob, options) {
   return ing.negated ? '!' + glob : glob;
 };
 
+function escape(path) {
+  return path.replace(/([({[\]})*?!])/g, '\\$1');
+}
+
+function unescape(path) {
+  return path.replace(/\\([({[\]})*?!])/g, '$1');
+}
+
+// Before calling unixify, we remove the escapes and then
+// we add them back afterwards to avoid double-escaping
 function unixify(filepath) {
   return filepath.replace(/\\/g, '/');
 }
diff --git a/package.json b/package.json
index 762ab5c..dc5db47 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "name": "to-absolute-glob",
   "description": "Make a glob pattern absolute, ensuring that negative globs and patterns with trailing slashes are correctly handled.",
-  "version": "2.0.2",
+  "version": "3.0.0",
   "homepage": "https://github.com/jonschlinkert/to-absolute-glob",
   "author": "Jon Schlinkert (https://github.com/jonschlinkert)",
   "contributors": [
@@ -30,8 +30,8 @@
     "is-negated-glob": "^1.0.0"
   },
   "devDependencies": {
-    "gulp-format-md": "^0.1.11",
-    "mocha": "^3.0.2"
+    "gulp-format-md": "^2.0.0",
+    "mocha": "^10.1.0"
   },
   "keywords": [
     "absolute",
diff --git a/readme.md b/readme.md
index d93fbed..3941bc6 100644
--- a/readme.md
+++ b/readme.md
@@ -7,13 +7,20 @@
 Install with [npm](https://www.npmjs.com/):
 
 ```sh
-$ npm install --save to-absolute-glob
+npm install to-absolute-glob
+```
+
+
+Or install with [yarn](https://yarnpkg.com/):
+
+```sh
+yarn add to-absolute-glob
 ```
 
 ## Usage
 
 ```js
-var toAbsGlob = require('to-absolute-glob');
+const toAbsGlob = require('to-absolute-glob');
 toAbsGlob('a/*.js');
 //=> '/dev/foo/a/*.js'
 ```
@@ -113,7 +120,7 @@ Pull requests and stars are always welcome. For bugs and feature requests, [plea
 
 ### Contributors
 
-| **Commits** | **Contributor**<br/> | 
+| **Commits** | **Contributor**<br/> |
 | --- | --- |
 | 16 | [doowb](https://github.com/doowb) |
 | 15 | [jonschlinkert](https://github.com/jonschlinkert) |
@@ -147,9 +154,9 @@ $ npm install -d && npm test
 
 ### License
 
-Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
+Copyright (c) [Jon Schlinkert](https://github.com/jonschlinkert).
 Released under the [MIT license](https://github.com/jonschlinkert/to-absolute-glob/blob/master/LICENSE).
 
 ***
 
-_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.2.0, on October 17, 2016._
\ No newline at end of file
+_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v3.0.0, on November 17, 2022._
\ No newline at end of file
diff --git a/test.js b/test.js
index 4ecbb08..d530cbb 100644
--- a/test.js
+++ b/test.js
@@ -4,7 +4,6 @@ require('mocha');
 var path = require('path');
 var assert = require('assert');
 var resolve = require('./');
-var sep = path.sep;
 var fixture;
 var actual;
 
@@ -12,93 +11,149 @@ function unixify(filepath) {
   return filepath.replace(/\\/g, '/');
 }
 
-describe('resolve', function () {
-  describe('posix', function () {
-    it('should make a path absolute', function () {
+describe('resolve', function() {
+  describe('posix', function() {
+    it('should make a path absolute', function() {
       assert.equal(resolve('a'), unixify(path.resolve('a')));
     });
 
-    it('should make a glob absolute', function () {
+    it('should make a glob absolute', function() {
       assert.equal(resolve('a/*.js'), unixify(path.resolve('a/*.js')));
     });
 
-    it('should retain trailing slashes', function () {
+    it('should retain trailing slashes', function() {
       actual = resolve('a/*/');
       assert.equal(actual, unixify(path.resolve('a/*')) + '/');
       assert.equal(actual.slice(-1), '/');
     });
 
-    it('should retain trailing slashes with cwd', function () {
+    it('should retain trailing slashes with cwd', function() {
       fixture = 'fixtures/whatsgoingon/*/';
       actual = resolve(fixture, {cwd: __dirname});
       assert.equal(actual, unixify(path.resolve(fixture)) + '/');
       assert.equal(actual.slice(-1), '/');
     });
 
-    it('should handle ./ at the beginnnig of a glob', function () {
+    it('should handle ./ at the beginnnig of a glob', function() {
       fixture = './fixtures/whatsgoingon/*/';
       actual = resolve(fixture, {cwd: __dirname});
       assert.equal(actual, unixify(path.resolve(fixture)) + '/');
     });
 
-    it('should make a negative glob absolute', function () {
+    it('should make a negative glob absolute', function() {
       actual = resolve('!a/*.js');
       assert.equal(actual, '!' + unixify(path.resolve('a/*.js')));
     });
 
-    it('should make a negative extglob absolute', function () {
+    it('should make a negative extglob absolute', function() {
       actual = resolve('!(foo)');
       assert.equal(actual, unixify(path.resolve('!(foo)')));
     });
 
-    it('should make an escaped negative extglob absolute', function () {
+    it('should make an escaped negative extglob absolute', function() {
       actual = resolve('\\!(foo)');
       assert.equal(actual, unixify(path.resolve('.')) + '/\\!(foo)');
     });
 
-    it('should make a glob absolute from a cwd', function () {
+    it('should make a glob absolute from a cwd', function() {
       actual = resolve('a/*.js', {cwd: 'foo'});
       assert.equal(actual, unixify(path.resolve('foo/a/*.js')));
     });
 
-    it('should make a negative glob absolute from a cwd', function () {
+    it('should escape glob patterns in an absolute cwd', function() {
+      actual = resolve('a/*.js', {cwd: '/(foo)/[bar]/{baz}/*/**/?/!'});
+      var expected = unixify(path.resolve('/(foo)/[bar]/{baz}/*/**/?/!/a/*.js'))
+        .replace('/(foo)/[bar]/{baz}/*/**/?/!', '/\\(foo\\)/\\[bar\\]/\\{baz\\}/\\*/\\*\\*/\\?/\\!');
+      assert.equal(actual, expected);
+    });
+
+    it('should escape glob patterns in a relative cwd', function() {
+      actual = resolve('a/*.js', {cwd: '(foo)/[bar]/{baz}/*/**/?/!'});
+      var expected = unixify(path.resolve('(foo)/[bar]/{baz}/*/**/?/!/a/*.js'))
+        .replace('(foo)/[bar]/{baz}/*/**/?/!', '\\(foo\\)/\\[bar\\]/\\{baz\\}/\\*/\\*\\*/\\?/\\!');
+      assert.equal(actual, expected);
+    });
+
+    it('avoids double escaping in cwd', function() {
+      actual = resolve('a/*.js', {cwd: '/\\(foo\\)/\\[bar\\]/\\{baz\\}/\\*/\\*\\*/\\?/\\!'});
+      var expected = unixify(path.resolve('/(foo)/[bar]/{baz}/*/**/?/!/a/*.js'))
+        .replace('/(foo)/[bar]/{baz}/*/**/?/!', '/\\(foo\\)/\\[bar\\]/\\{baz\\}/\\*/\\*\\*/\\?/\\!');
+      assert.equal(actual, expected);
+    });
+
+    it('works with multiple characters in succession in cwd', function() {
+      actual = resolve('a/*.js', {cwd: '/((foo))/[[bar]]/{{baz}}'});
+      var expected = unixify(path.resolve('/((foo))/[[bar]]/{{baz}}/a/*.js'))
+        .replace('/((foo))/[[bar]]/{{baz}}', '/\\(\\(foo\\)\\)/\\[\\[bar\\]\\]/\\{\\{baz\\}\\}');
+      assert.equal(actual, expected);
+    });
+
+    it('should make a negative glob absolute from a cwd', function() {
       actual = resolve('!a/*.js', {cwd: 'foo'});
       assert.equal(actual, '!' + unixify(path.resolve('foo/a/*.js')));
     });
 
-    it('should make a glob absolute from a root path', function () {
+    it('should make a glob absolute from a root path', function() {
       actual = resolve('/a/*.js', {root: 'foo'});
       assert.equal(actual, unixify(path.resolve('foo/a/*.js')));
     });
 
-    it('should make a glob absolute from a root slash', function () {
+    it('should make a glob absolute from a root slash', function() {
       actual = resolve('/a/*.js', {root: '/'});
       assert.equal(actual, unixify(path.resolve('/a/*.js')));
     });
 
-    it('should make a glob absolute from a negative root path', function () {
+    it('should escape glob patterns in an absolute root', function() {
+      actual = resolve('/a/*.js', {root: '/(foo)/[bar]/{baz}/*/**/?/!'});
+      var expected = unixify(path.resolve('/(foo)/[bar]/{baz}/*/**/?/!/a/*.js'))
+        .replace('/(foo)/[bar]/{baz}/*/**/?/!', '/\\(foo\\)/\\[bar\\]/\\{baz\\}/\\*/\\*\\*/\\?/\\!');
+      assert.equal(actual, expected);
+    });
+
+    it('should escape glob patterns in a relative root', function() {
+      actual = resolve('/a/*.js', {root: '(foo)/[bar]/{baz}/*/**/?/!'});
+      var expected = unixify(path.resolve('(foo)/[bar]/{baz}/*/**/?/!/a/*.js'))
+        .replace('(foo)/[bar]/{baz}/*/**/?/!', '\\(foo\\)/\\[bar\\]/\\{baz\\}/\\*/\\*\\*/\\?/\\!');
+      assert.equal(actual, expected);
+    });
+
+    it('avoids double escaping in root', function() {
+      actual = resolve('/a/*.js', {root: '/\\(foo\\)/\\[bar\\]/\\{baz\\}/\\*/\\*\\*/\\?/\\!'});
+      var expected = unixify(path.resolve('/(foo)/[bar]/{baz}/*/**/?/!/a/*.js'))
+        .replace('/(foo)/[bar]/{baz}/*/**/?/!', '/\\(foo\\)/\\[bar\\]/\\{baz\\}/\\*/\\*\\*/\\?/\\!');
+      assert.equal(actual, expected);
+    });
+
+    it('works with multiple characters in succession in root', function() {
+      actual = resolve('/a/*.js', {root: '/((foo))/[[bar]]/{{baz}}'});
+      var expected = unixify(path.resolve('/((foo))/[[bar]]/{{baz}}/a/*.js'))
+        .replace('/((foo))/[[bar]]/{{baz}}', '/\\(\\(foo\\)\\)/\\[\\[bar\\]\\]/\\{\\{baz\\}\\}');
+      assert.equal(actual, expected);
+    });
+
+    it('should make a glob absolute from a negative root path', function() {
       actual = resolve('!/a/*.js', {root: 'foo'});
       assert.equal(actual, '!' + unixify(path.resolve('foo/a/*.js')));
     });
 
-    it('should make a negative glob absolute from a negative root path', function () {
-      actual = resolve('!/a/*.js', {root: '/'})
+    it('should make a negative glob absolute from a negative root path', function() {
+      actual = resolve('!/a/*.js', {root: '/'});
       assert.equal(actual, '!' + unixify(path.resolve('/a/*.js')));
     });
   });
 
-  describe('windows', function () {
-    it('should make an escaped negative extglob absolute', function () {
+  describe('windows', function() {
+    it('should make an escaped negative extglob absolute', function() {
       actual = resolve('foo/bar\\!(baz)');
       assert.equal(actual, unixify(path.resolve('foo/bar')) + '\\!(baz)');
     });
 
-    it('should make a glob absolute from a root path', function () {
+    it('should make a glob absolute from a root path', function() {
       actual = resolve('/a/*.js', {root: 'foo\\bar\\baz'});
       assert.equal(actual, unixify(path.resolve('foo/bar/baz/a/*.js')));
     });
 
-    it('should make a glob absolute from a root slash', function () {
+    it('should make a glob absolute from a root slash', function() {
       actual = resolve('/a/*.js', {root: '\\'});
       assert.equal(actual, unixify(path.resolve('/a/*.js')));
     });

Debdiff

File lists identical (after any substitutions)

No differences were encountered in the control files

More details

Full run details