Comparing version 0.1.0 to 0.1.1
History | ||
======= | ||
## 0.1.1 | ||
* Fix bug wherein `gitignore-parser` did not correctly match `.gitignore` glob | ||
patterns like `git` actually does. Switch to `parse-gitignore` library and | ||
add regression tests. | ||
[#9](https://github.com/FormidableLabs/denim/issues/9) | ||
## 0.1.0 | ||
@@ -5,0 +12,0 @@ |
@@ -7,3 +7,4 @@ "use strict"; | ||
var fs = require("fs-extra"); | ||
var ignoreParser = require("gitignore-parser"); | ||
var ignoreParser = require("parse-gitignore"); | ||
var mm = require("micromatch"); | ||
var isBinaryFile = require("isbinaryfile"); | ||
@@ -278,4 +279,12 @@ var fileType = require("file-type"); | ||
// Read source gitignore from templated or real filename. | ||
fs.readFile(ignoreFile.path, cb); | ||
// Read source gitignore from templated or real filename into parser. (SYNC). | ||
var ignoreGlobs; | ||
var loadErr; | ||
try { | ||
ignoreGlobs = ignoreParser(ignoreFile.path); | ||
} catch (err) { | ||
loadErr = err; | ||
} | ||
cb(loadErr, ignoreGlobs); | ||
}], | ||
@@ -288,4 +297,4 @@ | ||
// Get ignore filter (if any). | ||
var ignoreSrc = (results.loadIgnore || "").toString(); | ||
if (!ignoreSrc) { | ||
var ignoreGlobs = results.loadIgnore; | ||
if (!ignoreGlobs) { | ||
return void cb(null, results.walkTemplates); | ||
@@ -295,3 +304,2 @@ } | ||
// Have ignores. Process and filter. | ||
var gitignore = ignoreParser.compile(ignoreSrc); | ||
var filtered = results.walkTemplates.filter(function (stat) { | ||
@@ -302,6 +310,6 @@ // Get relative, resolved path. | ||
// Default include algorithm. | ||
var isIncluded = gitignore.accepts(relPath); | ||
var isIgnored = mm.any(relPath, ignoreGlobs); | ||
// Push to overridable filter function. | ||
return templatesFilter(relPath, isIncluded); | ||
return templatesFilter(relPath, !isIgnored); | ||
}); | ||
@@ -308,0 +316,0 @@ |
{ | ||
"name": "denim", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "A lightweight, npm-based template engine.", | ||
@@ -34,7 +34,8 @@ "repository": { | ||
"fs-extra": "^0.30.0", | ||
"gitignore-parser": "0.0.2", | ||
"inquirer": "^0.11.1", | ||
"isbinaryfile": "^3.0.0", | ||
"lodash": "^4.17.2", | ||
"micromatch": "^2.3.11", | ||
"nopt": "^3.0.6", | ||
"parse-gitignore": "^0.3.1", | ||
"tar": "^2.2.1", | ||
@@ -41,0 +42,0 @@ "temp": "^0.8.3" |
@@ -197,2 +197,34 @@ "use strict"; | ||
// Correctly applies git ignore rules. | ||
// Bug: https://github.com/FormidableLabs/denim/issues/9 | ||
it("allows npmignore, npmrc when npm is in gitignore", stdioWrap(function (done) { | ||
var stubs = mockFlow({ | ||
"templates": { | ||
".gitignore": ".npm\n", | ||
".npmignore": "holla", | ||
".npmrc": "// holla too", | ||
".npm": { | ||
"test.txt": "should be ignored" | ||
} | ||
} | ||
}); | ||
// Note: These have to match prompt fields + `destination` in order. | ||
stubs.prompt | ||
.reset() | ||
.onCall(0).yields("dest"); | ||
init({ argv: ["node", SCRIPT, "mock-module"] }, function (err) { | ||
if (err) { return void done(err); } | ||
expect(base.fileRead("dest/.gitignore")).to.contain(".npm"); | ||
expect(base.fileRead("dest/.npmignore")).to.contain("holla"); | ||
expect(base.fileRead("dest/.npmrc")).to.contain("holla"); | ||
expect(base.fileExists(".npm/test.txt")).to.be.false; | ||
done(); | ||
}); | ||
})); | ||
it("initializes a basic project", stdioWrap(function (done) { | ||
@@ -199,0 +231,0 @@ var stubs = mockFlow({ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
123962
2431
12
+ Addedmicromatch@^2.3.11
+ Addedparse-gitignore@^0.3.1
+ Addedarr-diff@2.0.0(transitive)
+ Addedarr-flatten@1.1.0(transitive)
+ Addedarray-unique@0.2.1(transitive)
+ Addedbraces@1.8.5(transitive)
+ Addedexpand-brackets@0.1.5(transitive)
+ Addedexpand-range@1.8.2(transitive)
+ Addedextglob@0.3.2(transitive)
+ Addedfilename-regex@2.0.1(transitive)
+ Addedfill-range@2.2.4(transitive)
+ Addedfor-in@1.0.2(transitive)
+ Addedfor-own@0.1.5(transitive)
+ Addedglob-base@0.3.0(transitive)
+ Addedglob-parent@2.0.0(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-dotfile@1.0.3(transitive)
+ Addedis-equal-shallow@0.1.3(transitive)
+ Addedis-extendable@0.1.1(transitive)
+ Addedis-extglob@1.0.0(transitive)
+ Addedis-glob@2.0.1(transitive)
+ Addedis-number@2.1.04.0.0(transitive)
+ Addedis-posix-bracket@0.1.1(transitive)
+ Addedis-primitive@2.0.0(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedisobject@2.1.0(transitive)
+ Addedkind-of@3.2.26.0.3(transitive)
+ Addedmath-random@1.0.4(transitive)
+ Addedmicromatch@2.3.11(transitive)
+ Addednormalize-path@2.1.1(transitive)
+ Addedobject.omit@2.0.1(transitive)
+ Addedparse-gitignore@0.3.1(transitive)
+ Addedparse-glob@3.0.4(transitive)
+ Addedpreserve@0.2.0(transitive)
+ Addedrandomatic@3.1.1(transitive)
+ Addedregex-cache@0.4.4(transitive)
+ Addedremove-trailing-separator@1.1.0(transitive)
+ Addedrepeat-element@1.1.4(transitive)
+ Addedrepeat-string@1.6.1(transitive)
- Removedgitignore-parser@0.0.2
- Removedgitignore-parser@0.0.2(transitive)