Comparing version 0.1.9 to 0.1.10
49
index.js
@@ -16,3 +16,3 @@ /** | ||
var rimraf = require('rimraf'); | ||
var glob = require('glob'); | ||
var glob = require('globule'); | ||
var YAML = require('js-yaml'); | ||
@@ -25,9 +25,2 @@ var _ = require('lodash'); | ||
/** | ||
* TODO: | ||
* - endsWith | ||
* - lastExt (last extension) | ||
* - readYFM? | ||
* - readContent? (returns the content of a page, without YFM) | ||
*/ | ||
@@ -154,5 +147,6 @@ // Normalize paths to use `/` | ||
var re = /[\w.-]+$/; | ||
if(re.exec(filepath)) { | ||
return re.exec(filepath)[0]; | ||
} else { | ||
try { | ||
var foo = re.exec(filepath)[0]; | ||
return foo; | ||
} catch(e) { | ||
return ''; | ||
@@ -162,2 +156,7 @@ } | ||
file.getFilename = function() { | ||
var filepath = path.join.apply(path, arguments); | ||
return filepath.split(path.sep).pop().split('/').pop(); | ||
}; | ||
// Strip the filename from a file path | ||
@@ -172,2 +171,3 @@ file.removeFilename = function() { | ||
// Filename without extension | ||
file.basename = function() { | ||
@@ -178,3 +178,3 @@ var filepath = path.join.apply(path, arguments); | ||
// Filename without extension | ||
// Filename without extension. Differs slightly from basename | ||
file.base = function() { | ||
@@ -318,3 +318,3 @@ var filepath = path.join.apply(path, arguments); | ||
var obj = {}; | ||
file.expandFiles(filepath, options).map(function (fp) { | ||
glob.find(filepath, options).map(function (fp) { | ||
var name = path.basename(fp, path.extname(fp)); | ||
@@ -473,3 +473,3 @@ if (file.isEmptyFile(fp)) { | ||
// file.delete was sourced from grunt.file | ||
// file.delete was sourced and modified from grunt.file | ||
// https://github.com/gruntjs/grunt/blob/master/lib/grunt/file.js | ||
@@ -615,15 +615,22 @@ // https://github.com/gruntjs/grunt/blob/master/LICENSE-MIT | ||
// Retrieve a specific file using globbing patterns. If | ||
// multiple matches are found, only the first is returned | ||
file.getFile = function(filepath, options) { | ||
var str = file.expandFiles(filepath, options)[0]; | ||
var str = glob.find(filepath, options)[0]; | ||
return str ? String(str) : null; | ||
}; | ||
// function fn(src) { | ||
// return src.match(/^file\.(.+) =/gim).map(function(match) { | ||
// return match.replace(/(file\.| =)/g, ''); | ||
// }); | ||
// }; | ||
// file.writeDataSync('tmp/fn.json', fn(file.readFileSync(__filename))); | ||
// @private | ||
// List out functions | ||
function fn(src) { | ||
return src.match(/^file\.(.+) =/gim).map(function(match) { | ||
return match.replace(/(file\.| =)/g, ''); | ||
}); | ||
}; | ||
// file.writeDataSync('tmp/fn.json', fn(file.readFileSync(__filename))); |
{ | ||
"name": "fs-utils", | ||
"version": "0.1.9", | ||
"version": "0.1.10", | ||
"description": "File system utils for Node.js projects.", | ||
@@ -26,3 +26,2 @@ "repository": { | ||
"dependencies": { | ||
"glob": "~3.2.8", | ||
"iconv-lite": "~0.2.11", | ||
@@ -33,6 +32,8 @@ "js-yaml": "~3.0.1", | ||
"rimraf": "~2.2.6", | ||
"async": "~0.2.9" | ||
"async": "~0.2.9", | ||
"globule": "~0.2.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "~1.17.0" | ||
"mocha": "~1.17.0", | ||
"chai": "~1.8.1" | ||
}, | ||
@@ -39,0 +40,0 @@ "keywords": [ |
@@ -514,2 +514,10 @@ /** | ||
describe('File name:', function() { | ||
it('should get the extension', function() { | ||
var expected = 'file.json'; | ||
var actual = file.filename('path/to/file.json'); | ||
expect(actual).to.eql(expected); | ||
}); | ||
}); | ||
describe('file extension:', function() { | ||
@@ -516,0 +524,0 @@ it('should get the extension', function() { |
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
42363
14
1117
2
+ Addedglobule@~0.2.0
+ Addedglobule@0.2.0(transitive)
+ Addedminimatch@0.2.14(transitive)
- Removedglob@~3.2.8