Comparing version 0.3.8 to 0.3.9
{ | ||
"name": "fs-utils", | ||
"version": "0.3.8", | ||
"version": "0.3.9", | ||
"main": [ | ||
@@ -5,0 +5,0 @@ "index.js" |
57
index.js
/** | ||
* fs-utils | ||
* fs-utils <https://github.com/assemble/fs-utils> | ||
* | ||
* Copyright (c) 2014 Jon Schlinkert, Brian Woodward, contributors. | ||
@@ -7,16 +8,13 @@ * Licensed under the MIT license. | ||
'use strict'; | ||
const fs = require('graceful-fs'); | ||
const os = require('os'); | ||
const path = require('path'); | ||
// Node.js | ||
var fs = require('graceful-fs'); | ||
var os = require('os'); | ||
var path = require('path'); | ||
// node_modules | ||
var async = require('async'); | ||
var glob = require('globule'); | ||
var rimraf = require('rimraf'); | ||
var YAML = require('js-yaml'); | ||
var template = require('template'); | ||
var _ = require('lodash'); | ||
const async = require('async'); | ||
const glob = require('globule'); | ||
const rimraf = require('rimraf'); | ||
const YAML = require('js-yaml'); | ||
const template = require('template'); | ||
const _ = require('lodash'); | ||
@@ -71,3 +69,3 @@ | ||
// Transform EOL | ||
var contents = (os.EOL === '\n') ? str : str.replace(file.EOLre, '\n'); | ||
var contents = (os.EOL === '\n') ? str : str.replace(os.EOL, '\n'); | ||
// Strip UTF BOM | ||
@@ -183,4 +181,6 @@ if (!file.preserveBOM && contents.charCodeAt(0) === 0xFEFF) { | ||
async.waterfall([ | ||
function (next) { fs.readFile(String(filepath), file.encoding(options), next); }, | ||
function (contents, next) { | ||
function (next) { | ||
fs.readFile(String(filepath), file.encoding(options), next); | ||
}, function (contents, next) { | ||
try { | ||
@@ -194,3 +194,3 @@ next(null, file.stripBOM(contents)); | ||
], | ||
callback); | ||
callback); | ||
@@ -384,9 +384,11 @@ }; | ||
// the latter and make this change. | ||
file.expandData = function (filepath, options) { | ||
var opts = _.extend({}, options); | ||
file.expandData = function (patterns, options) { | ||
var opts = options || {}; | ||
opts.data = opts.data || {}; | ||
var contents; | ||
glob.find(filepath, opts).map(function (filepath) { | ||
var name = file.basename(filepath); | ||
patterns = file.arrayify(patterns); | ||
file.expand(patterns, opts).map(function (filepath) { | ||
var name = file.name(filepath); | ||
if (file.isEmptyFile(filepath)) { | ||
@@ -474,3 +476,3 @@ if(opts.verbose) {console.warn('Skipping empty file:'.yellow, filepath);} | ||
file.mkdir(destpath, function (err) { | ||
if (err) { next(err); } | ||
if (err) { callback(err); } | ||
else { | ||
@@ -712,13 +714,2 @@ fs.writeFile(dest, content, callback); | ||
file.folder = function() { | ||
if (prefix) { | ||
prefix = prefix.substring(0, prefix.lastIndexOf('/')); | ||
if (prefix.indexOf('/') !== -1) { | ||
prefix = prefix.substring(prefix.lastIndexOf('/') + 1); | ||
} | ||
} | ||
return prefix; | ||
}; | ||
// Directory path | ||
@@ -725,0 +716,0 @@ file.dir = function() { |
{ | ||
"name": "fs-utils", | ||
"version": "0.3.8", | ||
"version": "0.3.9", | ||
"description": "File system extras and utilities to extend the Node.js fs module.", | ||
@@ -26,7 +26,6 @@ "repository": { | ||
"dependencies": { | ||
"async": "~0.2.9", | ||
"async": "~0.2.10", | ||
"globule": "~0.2.0", | ||
"graceful-fs": "~2.0.1", | ||
"iconv-lite": "~0.2.11", | ||
"js-yaml": "~3.0.1", | ||
"graceful-fs": "~2.0.3", | ||
"js-yaml": "~3.0.2", | ||
"lodash": "~2.4.1", | ||
@@ -33,0 +32,0 @@ "mkdirp": "~0.3.5", |
/** | ||
* fs-utils | ||
* fs-utils <https://github.com/assemble/fs-utils> | ||
* | ||
* Copyright (c) 2014 Jon Schlinkert, Brian Woodward, contributors. | ||
@@ -7,6 +8,6 @@ * Licensed under the MIT license. | ||
var expect = require('chai').expect; | ||
var path = require('path'); | ||
var file = require('../'); | ||
var cwd = process.cwd(); | ||
const expect = require('chai').expect; | ||
const path = require('path'); | ||
const file = require('../'); | ||
const cwd = process.cwd(); | ||
@@ -13,0 +14,0 @@ describe('file system methods', function () { |
/** | ||
* Assemble | ||
* fs-utils <https://github.com/assemble/fs-utils> | ||
* | ||
* Assemble <http://assemble.io> | ||
* Created and maintained by Jon Schlinkert and Brian Woodward | ||
* | ||
* Copyright (c) 2014 Upstage. | ||
* Licensed under the MIT License (MIT). | ||
* Copyright (c) 2014 Jon Schlinkert, Brian Woodward, contributors. | ||
* Licensed under the MIT license. | ||
*/ | ||
var expect = require('chai').expect; | ||
var file = require('../'); | ||
var path = require('path'); | ||
var cwd = process.cwd(); | ||
const expect = require('chai').expect; | ||
const file = require('../'); | ||
const path = require('path'); | ||
const cwd = process.cwd(); | ||
@@ -541,25 +538,1 @@ // Normalize slashes in some test results | ||
}); | ||
describe('cwd:', function() { | ||
it('should get the absolute cwd', function() { | ||
var expected = file.normalizeSlash(cwd); | ||
var actual = file.cwd(); | ||
expect(actual).to.eql(expected); | ||
}); | ||
it('should get the absolute path relative to the cwd given the parameters', function() { | ||
var expected = file.normalizeSlash(path.join(cwd, 'first', 'second', 'third')); | ||
var actual = file.cwd('first', 'second', 'third'); | ||
expect(actual).to.eql(expected); | ||
}); | ||
it('should change the cwd', function() { | ||
var expected = file.normalizeSlash(path.join(cwd, 'test', 'fixtures')); | ||
file.setCWD('test', 'fixtures'); | ||
var actual = file.normalizeSlash(process.cwd()); | ||
expect(actual).to.eql(expected); | ||
file.setCWD('..', '..'); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
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
8
53810
1503
- Removediconv-lite@~0.2.11
- Removediconv-lite@0.2.11(transitive)
Updatedasync@~0.2.10
Updatedgraceful-fs@~2.0.3
Updatedjs-yaml@~3.0.2