mem-fs-editor
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -7,2 +7,3 @@ 'use strict'; | ||
var glob = require('glob'); | ||
var globby = require('globby'); | ||
var _ = require('lodash'); | ||
@@ -22,3 +23,3 @@ var File = require('vinyl'); | ||
if (!glob.hasMagic(from)) { | ||
if (!Array.isArray(from) && !glob.hasMagic(from)) { | ||
return this._copySingle(from, to, options); | ||
@@ -33,3 +34,3 @@ } | ||
var globOptions = _.extend(options.globOptions || {}, { nodir: true }); | ||
var files = glob.sync(from, globOptions); | ||
var files = globby.sync(from, globOptions); | ||
var root = util.getCommonPath(from); | ||
@@ -36,0 +37,0 @@ |
@@ -5,3 +5,4 @@ 'use strict'; | ||
var _ = require('lodash'); | ||
var glob = require('glob'); | ||
var globby = require('globby'); | ||
var multimatch = require('multimatch'); | ||
var util = require('../util/util'); | ||
@@ -16,9 +17,8 @@ | ||
module.exports = function (path, options) { | ||
path = util.globify(path); | ||
options = options || { globOptions : {} }; | ||
module.exports = function (paths, options) { | ||
paths = util.globify(paths); | ||
options = options || {}; | ||
var globOptions = _.extend(options.globOptions, { sync: true }); | ||
var g = new glob.Glob(path, globOptions); | ||
var files = g.found; | ||
var globOptions = options.globOptions || {}; | ||
var files = globby.sync(paths, globOptions); | ||
files.forEach(function (file) { | ||
@@ -29,3 +29,3 @@ deleteFile(file, this.store); | ||
this.store.each(function (file) { | ||
if (g.minimatch.match(file.path)) { | ||
if (multimatch(paths, file.path).length !== 0) { | ||
deleteFile(file.path, this.store); | ||
@@ -32,0 +32,0 @@ } |
@@ -6,5 +6,5 @@ 'use strict'; | ||
module.exports = function (path, contents, replacer, space) { | ||
var jsonStr = JSON.stringify(contents, replacer || null, space || DEFAULT_INDENTATION); | ||
var jsonStr = JSON.stringify(contents, replacer || null, space || DEFAULT_INDENTATION) + '\n'; | ||
return this.write(path, jsonStr); | ||
}; |
{ | ||
"name": "mem-fs-editor", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "File edition helpers working on top of mem-fs", | ||
@@ -17,6 +17,9 @@ "scripts": { | ||
"dependencies": { | ||
"commondir": "^1.0.1", | ||
"ejs": "^2.3.1", | ||
"glob": "^5.0.3", | ||
"globby": "^2.0.0", | ||
"lodash": "^3.6.0", | ||
"mkdirp": "^0.5.0", | ||
"multimatch": "^2.0.0", | ||
"rimraf": "^2.2.8", | ||
@@ -23,0 +26,0 @@ "sinon": "^1.12.2", |
@@ -5,5 +5,18 @@ 'use strict'; | ||
var path = require('path'); | ||
var commondir = require('commondir'); | ||
var glob = require('glob'); | ||
function notNullOrExclusion(file) { | ||
return file != null && file.charAt(0) !== '!'; | ||
} | ||
exports.getCommonPath = function (filePath) { | ||
if (Array.isArray(filePath)) { | ||
filePath = filePath | ||
.filter(notNullOrExclusion) | ||
.map(this.getCommonPath.bind(this)); | ||
return commondir(filePath); | ||
} | ||
filePath = this.globify(filePath); | ||
@@ -18,4 +31,7 @@ var globStartIndex = filePath.indexOf('*'); | ||
exports.globify = function (filePath) { | ||
if (Array.isArray(filePath)) { | ||
return filePath.map(this.globify.bind(this)); | ||
} | ||
exports.globify = function (filePath) { | ||
if (glob.hasMagic(filePath) || !fs.existsSync(filePath)) { | ||
@@ -22,0 +38,0 @@ return filePath; |
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
12807
241
11
+ Addedcommondir@^1.0.1
+ Addedglobby@^2.0.0
+ Addedmultimatch@^2.0.0
+ Addedarray-differ@1.0.0(transitive)
+ Addedarray-union@1.0.2(transitive)
+ Addedarray-uniq@1.0.3(transitive)
+ Addedarrify@1.0.1(transitive)
+ Addedasync@1.5.2(transitive)
+ Addedcommondir@1.0.1(transitive)
+ Addedglobby@2.1.0(transitive)
+ Addedmultimatch@2.1.0(transitive)
+ Addedobject-assign@3.0.0(transitive)