Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fs-utils

Package Overview
Dependencies
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fs-utils - npm Package Compare versions

Comparing version 0.3.5 to 0.3.6

2

bower.json
{
"name": "fs-utils",
"version": "0.3.5",
"version": "0.3.6",
"main": [

@@ -5,0 +5,0 @@ "index.js"

@@ -219,11 +219,11 @@ /**

file.readDataSync = function(filepath, options) {
options = options || {};
var ext = path.extname(filepath);
var opts = _.extend({}, options);
var ext = opts.parse || file.ext(filepath);
var reader = file.readJSONSync;
switch(ext) {
case '.json':
case 'json':
reader = file.readJSONSync;
break;
case '.yml':
case '.yaml':
case 'yml':
case 'yaml':
reader = file.readYAMLSync;

@@ -314,3 +314,3 @@ break;

glob.find(filepath, opts).map(function (filepath) {
var name = _path.basename(filepath);
var name = file.basename(filepath);
if (file.isEmptyFile(filepath)) {

@@ -573,6 +573,3 @@ if(opts.verbose) {console.warn('Skipping empty file:'.yellow, filepath);}

// First segment of a file path
file.firstDir = function (f) {
var filepath = path.join.apply(path, arguments);
return _.initial(filepath.split('/')).join('/');
};
file.firstDir = file.firstSegment;

@@ -650,3 +647,5 @@ // Directory path

// Ensure that filepath has trailing slash
// Ensure that filepath has trailing slash. Alternate
// to `addTrailingSlash`. One of these will be deprecated
// after more tests, and we'll keep the name `slashify`.
file.slashify = function () {

@@ -653,0 +652,0 @@ var filepath = path.join.apply(path, arguments);

{
"name": "fs-utils",
"version": "0.3.5",
"version": "0.3.6",
"description": "File system extras and utilities to extend the Node.js fs module.",

@@ -5,0 +5,0 @@ "repository": {

@@ -11,9 +11,9 @@ /**

var expect = require('chai').expect;
var pathUtils = require('../');
var path = require('path');
var cwd = process.cwd();
var expect = require('chai').expect;
var file = require('../');
var path = require('path');
var cwd = process.cwd();
// Normalize slashes in some test results
var normalize = pathUtils.normalizeSlash;
var normalize = file.normalizeSlash;

@@ -23,7 +23,7 @@ describe('Normalize slashes', function() {

var expected = 'foo/bar/baz';
var actual = pathUtils.normalizeSlash('foo\\bar/baz');
var actual = file.normalizeSlash('foo\\bar/baz');
expect(actual).to.eql(expected);
expected = '/foo/bar/baz/';
actual = pathUtils.normalizeSlash('\\foo\\bar\\baz\\');
actual = file.normalizeSlash('\\foo\\bar\\baz\\');
expect(actual).to.eql(expected);

@@ -37,23 +37,23 @@ });

var expected = 'foo/bar/baz/';
var actual = pathUtils.addTrailingSlash('foo/bar/baz');
var actual = file.addTrailingSlash('foo/bar/baz');
expect(normalize(actual)).to.eql(expected);
expected = '/foo/bar/baz/';
actual = pathUtils.addTrailingSlash('/foo/bar/baz');
actual = file.addTrailingSlash('/foo/bar/baz');
expect(normalize(actual)).to.eql(expected);
expected = 'foo/bar.baz/quux/';
actual = pathUtils.addTrailingSlash('./foo/bar.baz/quux');
actual = file.addTrailingSlash('./foo/bar.baz/quux');
expect(normalize(actual)).to.eql(expected);
expected = 'foo/bar/baz/';
actual = pathUtils.addTrailingSlash('./foo/bar/baz');
actual = file.addTrailingSlash('./foo/bar/baz');
expect(normalize(actual)).to.eql(expected);
expected = '/foo/bar/baz/';
actual = pathUtils.addTrailingSlash('\\foo\\bar\\baz');
actual = file.addTrailingSlash('\\foo\\bar\\baz');
expect(normalize(actual)).to.eql(expected);
expected = 'foo/bar/baz/';
actual = pathUtils.addTrailingSlash('foo\\bar\\baz');
actual = file.addTrailingSlash('foo\\bar\\baz');
expect(normalize(actual)).to.eql(expected);

@@ -64,7 +64,7 @@ });

var expected = 'foo/bar/baz/';
var actual = pathUtils.addTrailingSlash('foo/bar/baz/');
var actual = file.addTrailingSlash('foo/bar/baz/');
expect(normalize(actual)).to.eql(expected);
expected = '/foo/bar/baz/';
actual = pathUtils.addTrailingSlash('/foo/bar/baz/');
actual = file.addTrailingSlash('/foo/bar/baz/');
expect(normalize(actual)).to.eql(expected);

@@ -75,11 +75,11 @@ });

var expected = 'foo/bar/baz.md';
var actual = pathUtils.addTrailingSlash('./foo/bar/baz.md');
var actual = file.addTrailingSlash('./foo/bar/baz.md');
expect(normalize(actual)).to.eql(expected);
expected = '/foo/bar/baz.md';
actual = pathUtils.addTrailingSlash('/foo/bar/baz.md');
actual = file.addTrailingSlash('/foo/bar/baz.md');
expect(normalize(actual)).to.eql(expected);
expected = '/foo/bar/baz.md';
actual = pathUtils.addTrailingSlash('\\foo\\bar\\baz.md');
actual = file.addTrailingSlash('\\foo\\bar\\baz.md');
expect(normalize(actual)).to.eql(expected);

@@ -92,11 +92,11 @@ });

var expected = 'one/two';
var actual = pathUtils.removeTrailingSlash('./one/two/');
var actual = file.removeTrailingSlash('./one/two/');
expect(normalize(actual)).to.eql(expected);
expected = '/three/four/five';
actual = pathUtils.removeTrailingSlash('/three/four/five/');
actual = file.removeTrailingSlash('/three/four/five/');
expect(normalize(actual)).to.eql(expected);
expected = '/six/seven/eight';
actual = pathUtils.removeTrailingSlash('\\six\\seven\\eight\\');
actual = file.removeTrailingSlash('\\six\\seven\\eight\\');
expect(normalize(actual)).to.eql(expected);

@@ -111,19 +111,19 @@ });

var expected = true;
var actual = pathUtils.endsWith('foo\\bar\\baz\\', '/');
var actual = file.endsWith('foo\\bar\\baz\\', '/');
expect(actual).to.eql(expected);
expected = true;
actual = pathUtils.endsWith('foo\\bar\\baz\\', '\\');
actual = file.endsWith('foo\\bar\\baz\\', '\\');
expect(actual).to.eql(expected);
expected = true;
actual = pathUtils.endsWith('foo/bar/baz/', '/');
actual = file.endsWith('foo/bar/baz/', '/');
expect(actual).to.eql(expected);
expected = true;
actual = pathUtils.endsWith('foo\\bar\\baz.md', 'baz.md');
actual = file.endsWith('foo\\bar\\baz.md', 'baz.md');
expect(actual).to.eql(expected);
expected = true;
actual = pathUtils.endsWith('foo\\bar\\baz.md', '.md');
actual = file.endsWith('foo\\bar\\baz.md', '.md');
expect(actual).to.eql(expected);

@@ -134,7 +134,7 @@ });

var expected = false;
var actual = pathUtils.endsWith('foo\\bar\\baz.md', '/');
var actual = file.endsWith('foo\\bar\\baz.md', '/');
expect(actual).to.eql(expected);
expected = false;
actual = pathUtils.endsWith('foo\\bar\\baz.md', 'baz');
actual = file.endsWith('foo\\bar\\baz.md', 'baz');
expect(actual).to.eql(expected);

@@ -147,19 +147,19 @@ });

var expected = 'md';
var actual = pathUtils.lastExt('foo/bar/baz/quux.bar/file.tmpl.md');
var actual = file.lastExt('foo/bar/baz/quux.bar/file.tmpl.md');
expect(actual).to.eql(expected);
expected = 'md';
actual = pathUtils.lastExt('./foo/bar/baz/quux.bar/file.tmpl.md');
actual = file.lastExt('./foo/bar/baz/quux.bar/file.tmpl.md');
expect(actual).to.eql(expected);
expected = '';
actual = pathUtils.lastExt('foo/bar/baz/quux.bar/CHANGELOG');
actual = file.lastExt('foo/bar/baz/quux.bar/CHANGELOG');
expect(actual).to.eql(expected);
expected = 'gitignore';
actual = pathUtils.lastExt('/foo/bar/baz/quux.bar/.gitignore');
actual = file.lastExt('/foo/bar/baz/quux.bar/.gitignore');
expect(actual).to.eql(expected);
expected = 'html';
actual = pathUtils.lastExt('./foo/bar/baz/quux/index.html');
actual = file.lastExt('./foo/bar/baz/quux/index.html');
expect(actual).to.eql(expected);

@@ -173,7 +173,7 @@ });

var expected = ['test.txt'];
var actual = pathUtils.withExt('./test/fixtures', 'txt');
var actual = file.withExt('./test/fixtures', 'txt');
expect(actual).to.eql(expected);
expected = ['fs-tests.js', 'path-tests.js'];
actual = pathUtils.withExt('./test', 'js');
actual = file.withExt('./test', 'js');
expect(actual).to.eql(expected);

@@ -187,11 +187,11 @@ });

var expected = 'apple';
var actual = pathUtils.firstSegment('apple/orange/file.ext');
var actual = file.firstSegment('apple/orange/file.ext');
expect(actual).to.eql(expected);
expected = 'grape';
actual = pathUtils.firstSegment('/grape/watermelon/quux');
actual = file.firstSegment('/grape/watermelon/quux');
expect(actual).to.eql(expected);
expected = 'banana';
actual = pathUtils.firstSegment('./banana/strawberry/quux/');
actual = file.firstSegment('./banana/strawberry/quux/');
expect(actual).to.eql(expected);

@@ -204,11 +204,11 @@ });

var expected = 'file.ext';
var actual = pathUtils.lastSegment('square/rectangle/file.ext');
var actual = file.lastSegment('square/rectangle/file.ext');
expect(actual).to.eql(expected);
expected = 'four';
actual = pathUtils.lastSegment('one/two/three/four');
actual = file.lastSegment('one/two/three/four');
expect(actual).to.eql(expected);
expected = 'grape';
actual = pathUtils.lastSegment('apple/orange/grape/');
actual = file.lastSegment('apple/orange/grape/');
expect(actual).to.eql(expected);

@@ -221,11 +221,11 @@ });

var expected = 'square/rectangle/';
var actual = pathUtils.removeFilename('square/rectangle/file.ext');
var actual = file.removeFilename('square/rectangle/file.ext');
expect(normalize(actual)).to.eql(expected);
expected = 'one/two/three/four';
actual = pathUtils.removeFilename('one/two/three/four');
actual = file.removeFilename('one/two/three/four');
expect(normalize(actual)).to.eql(expected);
expected = 'apple/orange/grape/';
actual = pathUtils.removeFilename('apple/orange/grape/');
actual = file.removeFilename('apple/orange/grape/');
expect(normalize(actual)).to.eql(expected);

@@ -239,11 +239,11 @@ });

var expected = 'square/rectangle/';
var actual = pathUtils.dirname('square/rectangle/file.ext');
var actual = file.dirname('square/rectangle/file.ext');
expect(normalize(actual)).to.eql(expected);
expected = 'one/two/three/';
actual = pathUtils.dirname('one/two/three/four');
actual = file.dirname('one/two/three/four');
expect(normalize(actual)).to.eql(expected);
expected = 'apple/orange/grape/';
actual = pathUtils.dirname('apple/orange/grape/');
actual = file.dirname('apple/orange/grape/');
expect(normalize(actual)).to.eql(expected);

@@ -254,15 +254,15 @@ });

var expected = 'square/rectangle/';
var actual = pathUtils.dir('square/rectangle/file.ext');
var actual = file.dir('square/rectangle/file.ext');
expect(normalize(actual)).to.eql(expected);
expected = 'one/two/three/four';
actual = pathUtils.dir('one/two/three/four');
actual = file.dir('one/two/three/four');
expect(normalize(actual)).to.eql(expected);
expected = 'one/two/three/CHANGELOG';
actual = pathUtils.dir('one/two/three/CHANGELOG');
actual = file.dir('one/two/three/CHANGELOG');
expect(normalize(actual)).to.eql(expected);
expected = 'apple/orange/grape/';
actual = pathUtils.dir('./apple/orange/grape/');
actual = file.dir('./apple/orange/grape/');
expect(normalize(actual)).to.eql(expected);

@@ -276,11 +276,11 @@ });

var expected = 'apple';
var actual = pathUtils.firstDir('apple/orange/file.ext');
var actual = file.firstDir('apple/orange/file.ext');
expect(actual).to.eql(expected);
expected = 'grape';
actual = pathUtils.firstDir('/grape/watermelon/quux');
actual = file.firstDir('/grape/watermelon/quux');
expect(actual).to.eql(expected);
expected = 'banana';
actual = pathUtils.firstDir('./banana/strawberry/quux/');
actual = file.firstDir('./banana/strawberry/quux/');
expect(actual).to.eql(expected);

@@ -294,11 +294,11 @@ });

var expected = 'rectangle';
var actual = pathUtils.lastDir('square/rectangle/file.ext');
var actual = file.lastDir('square/rectangle/file.ext');
expect(normalize(actual)).to.eql(expected);
expected = 'four';
actual = pathUtils.lastDir('one/two/three/four');
actual = file.lastDir('one/two/three/four');
expect(normalize(actual)).to.eql(expected);
expected = 'grape';
actual = pathUtils.lastDir('apple/orange/grape/');
actual = file.lastDir('apple/orange/grape/');
expect(normalize(actual)).to.eql(expected);

@@ -312,11 +312,11 @@ });

var expected = 't';
var actual = pathUtils.lastChar('foo/bar/baz/quux/file.ext');
var actual = file.lastChar('foo/bar/baz/quux/file.ext');
expect(actual).to.eql(expected);
expected = 'x';
actual = pathUtils.lastChar('foo/bar/baz/quux');
actual = file.lastChar('foo/bar/baz/quux');
expect(actual).to.eql(expected);
expected = '/';
actual = pathUtils.lastChar('foo/bar/baz/quux/');
actual = file.lastChar('foo/bar/baz/quux/');
expect(actual).to.eql(expected);

@@ -429,39 +429,39 @@ });

var expected = 'file.json';
var actual = pathUtils.filename('path/to/file.json');
var actual = file.filename('path/to/file.json');
expect(actual).to.eql(expected);
expected = 'file.tmpl.md';
actual = pathUtils.filename('path/to/file.tmpl.md');
actual = file.filename('path/to/file.tmpl.md');
expect(actual).to.eql(expected);
expected = 'file';
actual = pathUtils.filename('path/to/file');
actual = file.filename('path/to/file');
expect(actual).to.eql(expected);
expected = 'baz.quux';
actual = pathUtils.filename('.foo.bar/baz.quux');
actual = file.filename('.foo.bar/baz.quux');
expect(actual).to.eql(expected);
expected = 'baz.quux.';
actual = pathUtils.filename('.foo.bar/baz.quux.');
actual = file.filename('.foo.bar/baz.quux.');
expect(actual).to.eql(expected);
expected = '.html';
actual = pathUtils.filename('.html');
actual = file.filename('.html');
expect(actual).to.eql(expected);
expected = 'foo.bar.baz.quux';
actual = pathUtils.filename('/foo.bar.baz.quux');
actual = file.filename('/foo.bar.baz.quux');
expect(actual).to.eql(expected);
expected = 'quux';
actual = pathUtils.filename('/foo/bar/baz/asdf/quux');
actual = file.filename('/foo/bar/baz/asdf/quux');
expect(actual).to.eql(expected);
expected = 'quux.html';
actual = pathUtils.filename('/foo/bar/baz/asdf/quux.html');
actual = file.filename('/foo/bar/baz/asdf/quux.html');
expect(actual).to.eql(expected);
expected = 'quux';
actual = pathUtils.filename('/foo/bar/baz/quux');
actual = file.filename('/foo/bar/baz/quux');
expect(actual).to.eql(expected);

@@ -471,7 +471,7 @@

expected = '';
actual = pathUtils.filename('/foo/bar/baz/quux/');
actual = file.filename('/foo/bar/baz/quux/');
expect(actual).to.eql(expected);
expected = 'quux';
actual = pathUtils.filename('/quux');
actual = file.filename('/quux');
expect(actual).to.eql(expected);

@@ -481,15 +481,15 @@

expected = '';
actual = pathUtils.filename('/quux/');
actual = file.filename('/quux/');
expect(actual).to.eql(expected);
expected = 'foo.bar.baz.quux';
actual = pathUtils.filename('foo.bar.baz.quux');
actual = file.filename('foo.bar.baz.quux');
expect(actual).to.eql(expected);
expected = 'baz.quux';
actual = pathUtils.filename('foo.bar/baz.quux');
actual = file.filename('foo.bar/baz.quux');
expect(actual).to.eql(expected);
expected = 'bar.baz.quux';
actual = pathUtils.filename('foo/bar.baz.quux');
actual = file.filename('foo/bar.baz.quux');
expect(actual).to.eql(expected);

@@ -499,19 +499,19 @@

expected = '';
actual = pathUtils.filename('foo/bar.baz.quux/');
actual = file.filename('foo/bar.baz.quux/');
expect(actual).to.eql(expected);
expected = 'quux';
actual = pathUtils.filename('foo/bar.baz/quux');
actual = file.filename('foo/bar.baz/quux');
expect(actual).to.eql(expected);
expected = 'baz.quux';
actual = pathUtils.filename('foo/bar/baz.quux');
actual = file.filename('foo/bar/baz.quux');
expect(actual).to.eql(expected);
expected = 'baz.quux.';
actual = pathUtils.filename('foo/bar/baz.quux.');
actual = file.filename('foo/bar/baz.quux.');
expect(actual).to.eql(expected);
expected = 'quux';
actual = pathUtils.filename('foo/bar/baz/quux');
actual = file.filename('foo/bar/baz/quux');
expect(actual).to.eql(expected);

@@ -521,3 +521,3 @@

expected = '';
actual = pathUtils.filename('foo/bar/baz/quux/');
actual = file.filename('foo/bar/baz/quux/');
expect(actual).to.eql(expected);

@@ -527,3 +527,3 @@

expected = '';
actual = pathUtils.filename('foo\\bar\\baz\\quux\\');
actual = file.filename('foo\\bar\\baz\\quux\\');
expect(actual).to.eql(expected);

@@ -533,3 +533,3 @@

expected = '';
actual = pathUtils.filename('quux/');
actual = file.filename('quux/');
expect(actual).to.eql(expected);

@@ -542,3 +542,3 @@ });

var expected = 'file.json';
var actual = pathUtils.filename('path/to/file.json');
var actual = file.filename('path/to/file.json');
expect(actual).to.eql(expected);

@@ -551,3 +551,3 @@ });

var expected = 'json';
var actual = pathUtils.ext('path/to/file.json');
var actual = file.ext('path/to/file.json');
expect(actual).to.eql(expected);

@@ -558,3 +558,3 @@ });

var expected = 'file';
var actual = pathUtils.basename('path/to/file.json');
var actual = file.basename('path/to/file.json');
expect(actual).to.eql(expected);

@@ -565,3 +565,3 @@ });

var expected = 'file';
var actual = pathUtils.base('path/to/file.json');
var actual = file.base('path/to/file.json');
expect(actual).to.eql(expected);

@@ -574,4 +574,4 @@ });

it('should get the absolute cwd', function() {
var expected = pathUtils.normalizeSlash(cwd);
var actual = pathUtils.cwd();
var expected = file.normalizeSlash(cwd);
var actual = file.cwd();
expect(actual).to.eql(expected);

@@ -581,4 +581,4 @@ });

it('should get the absolute path relative to the cwd given the parameters', function() {
var expected = pathUtils.normalizeSlash(path.join(cwd, 'first', 'second', 'third'));
var actual = pathUtils.cwd('first', 'second', 'third');
var expected = file.normalizeSlash(path.join(cwd, 'first', 'second', 'third'));
var actual = file.cwd('first', 'second', 'third');
expect(actual).to.eql(expected);

@@ -588,9 +588,9 @@ });

it('should change the cwd', function() {
var expected = pathUtils.normalizeSlash(path.join(cwd, 'test', 'fixtures'));
pathUtils.setCWD('test', 'fixtures');
var actual = pathUtils.normalizeSlash(process.cwd());
var expected = file.normalizeSlash(path.join(cwd, 'test', 'fixtures'));
file.setCWD('test', 'fixtures');
var actual = file.normalizeSlash(process.cwd());
expect(actual).to.eql(expected);
pathUtils.setCWD('..', '..');
file.setCWD('..', '..');
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc