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

fs.extra

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fs.extra - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

10

fs.copy.js

@@ -9,3 +9,9 @@ (function () {

function copy(src, dst, cb) {
function copy(src, dst, opts, cb) {
if ('function' === typeof opts) {
cb = opts;
opts = null;
}
opts = opts || {};
function copyHelper(err) {

@@ -16,3 +22,3 @@ var is

if (!err) {
if (!err && !opts.replace) {
return cb(new Error("File " + dst + " exists."));

@@ -19,0 +25,0 @@ }

6

package.json
{
"author": "AJ ONeal <coolaj86@gmail.com> (http://coolaj86.info/)",
"author": "AJ ONeal <awesome@coolaj86@.com> (http://coolaj86.com/)",
"name": "fs.extra",
"description": "fs.move and fs.copy for Node.JS",
"version": "1.2.1",
"version": "1.3.0",
"repository": {
"type": "git",
"url": "git://github.com/coolaj86/node-examples-js.git"
"url": "git://github.com/coolaj86/utile-fs.git"
},

@@ -10,0 +10,0 @@ "main": "fs.extra",

fs.extra
===
Adds `copy`, `copyRecursive`, `mkdirp`, `move`, `walk`, and `rmrf` to Node.JS' `fs`.
Extra file utilities for node.js
Install with `npm install -S fs.extra`
**Includes**
// this will have all of the normal fs methods
var fs = require('fs.extra');
* `copy`
* `copyRecursive`
* `mkdirp`
* `move`
* `walk`
* `rmrf`
**Install**
``` bash
npm install --save fs.extra
````
**Usage**
```javascript
// this will have all of a copy of the normal fs methods as well
var fs = require('fs.extra');
```
fs.copy

@@ -16,10 +33,15 @@ ===

fs.copy('foo.txt', 'bar.txt', function (err) {
if (err) {
throw err;
}
```javascript
fs.copy('foo.txt', 'bar.txt', { replace: false }, function (err) {
if (err) {
// i.e. file already exists or can't write to directory
throw err;
}
console.log("Copied 'foo.txt' to 'bar.txt');
});
console.log("Copied 'foo.txt' to 'bar.txt');
});
```
Options are optional. `replace` defaults to false, but will replace existing files if set to `true`.
fs.copyRecursive

@@ -30,9 +52,11 @@ ===

fs.copyRecursive('./foo', './bar', function (err) {
if (err) {
throw err;
}
```javascript
fs.copyRecursive('./foo', './bar', function (err) {
if (err) {
throw err;
}
console.log("Copied './foo' to './bar');
});
console.log("Copied './foo' to './bar');
});
```

@@ -44,11 +68,13 @@ fs.mkdirRecursive

// fs.mkdirp(path, mode=(0777 & (~process.umask())), cb);
```javascript
// fs.mkdirp(path, mode=(0777 & (~process.umask())), cb);
fs.mkdirp('/tmp/foo/bar/baz', function (err) {
if (err) {
console.error(err);
} else {
console.log('pow!')
}
});
fs.mkdirp('/tmp/foo/bar/baz', function (err) {
if (err) {
console.error(err);
} else {
console.log('pow!')
}
});
```

@@ -60,9 +86,11 @@ fs.mkdirRecursiveSync

// fs.mkdirpSync(path, mode=(0777 & (~process.umask())));
```javascript
// fs.mkdirpSync(path, mode=(0777 & (~process.umask())));
try {
fs.mkdirpSync('/tmp/foo/bar/baz');
} catch(e) {
throw e;
}
try {
fs.mkdirpSync('/tmp/foo/bar/baz');
} catch(e) {
throw e;
}
```

@@ -74,9 +102,11 @@ fs.move

fs.move('foo.txt', 'bar.txt', function (err) {
if (err) {
throw err;
}
```javascript
fs.move('foo.txt', 'bar.txt', function (err) {
if (err) {
throw err;
}
console.log("Moved 'foo.txt' to 'bar.txt');
});
console.log("Moved 'foo.txt' to 'bar.txt');
});
```

@@ -90,9 +120,11 @@ fs.rmRecursive

// fs.rmrf(dir, callback);
```javascript
// fs.rmrf(dir, callback);
fs.rmrf('/choose/me/carefully/', function (err) {
if (err) {
console.error(err);
}
});
fs.rmrf('/choose/me/carefully/', function (err) {
if (err) {
console.error(err);
}
});
```

@@ -106,5 +138,7 @@ fs.rmRecursiveSync

// fs.rmrfSync(dir);
```javascript
// fs.rmrfSync(dir);
fs.rmrfSync('/choose/me/carefully/');
fs.rmrfSync('/choose/me/carefully/');
```

@@ -116,12 +150,14 @@ fs.walk

var walker = fs.walk(dir)
;
```javascript
var walker = fs.walk(dir)
;
// file, files, directory, directories
walker.on("file", function (root, stat, next) {
var filepath = path.join(root, stat.name)
;
// file, files, directory, directories
walker.on("file", function (root, stat, next) {
var filepath = path.join(root, stat.name)
;
console.log(filepath);
});
console.log(filepath);
});
```

@@ -141,3 +177,3 @@ Aliases and Backwards Compatibility

Copyright AJ ONeal 2011-2012
Copyright AJ ONeal 2011-2015

@@ -144,0 +180,0 @@ This project is available under the MIT and Apache v2 licenses.

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