JP Richardson
12 years ago
15 changed files with 228 additions and 315 deletions
@ -0,0 +1,4 @@ |
|||
language: node_js |
|||
node_js: |
|||
- 0.6 |
|||
- 0.8 |
@ -1,48 +1,42 @@ |
|||
// Generated by CoffeeScript 1.3.3
|
|||
(function() { |
|||
var BUF_LENGTH, copy, copyFile, copyFileSync, fs, ncp, _buff; |
|||
|
|||
fs = require('fs'); |
|||
|
|||
ncp = require('ncp').ncp; |
|||
|
|||
BUF_LENGTH = 64 * 1024; |
|||
|
|||
_buff = new Buffer(BUF_LENGTH); |
|||
|
|||
copyFileSync = function(srcFile, destFile) { |
|||
var bytesRead, fdr, fdw, pos; |
|||
fdr = fs.openSync(srcFile, 'r'); |
|||
fdw = fs.openSync(destFile, 'w'); |
|||
bytesRead = 1; |
|||
pos = 0; |
|||
while (bytesRead > 0) { |
|||
bytesRead = fs.readSync(fdr, _buff, 0, BUF_LENGTH, pos); |
|||
fs.writeSync(fdw, _buff, 0, bytesRead); |
|||
pos += bytesRead; |
|||
} |
|||
fs.closeSync(fdr); |
|||
return fs.closeSync(fdw); |
|||
}; |
|||
|
|||
copyFile = function(srcFile, destFile, cb) { |
|||
var fdr, fdw; |
|||
fdr = fs.createReadStream(srcFile); |
|||
fdw = fs.createWriteStream(destFile); |
|||
fdr.on('end', function() { |
|||
return cb(null); |
|||
}); |
|||
return fdr.pipe(fdw); |
|||
}; |
|||
|
|||
copy = function(source, dest, callback) { |
|||
return ncp(source, dest, callback); |
|||
}; |
|||
|
|||
module.exports.copyFileSync = copyFileSync; |
|||
|
|||
module.exports.copyFile = copyFile; |
|||
|
|||
module.exports.copy = copy; |
|||
|
|||
}).call(this); |
|||
var fs = require('fs') |
|||
, ncp = require('ncp').ncp; |
|||
|
|||
var BUF_LENGTH = 64 * 1024; |
|||
var _buff = new Buffer(BUF_LENGTH); |
|||
|
|||
copyFileSync = function(srcFile, destFile) { |
|||
var bytesRead, fdr, fdw, pos; |
|||
fdr = fs.openSync(srcFile, 'r'); |
|||
fdw = fs.openSync(destFile, 'w'); |
|||
bytesRead = 1; |
|||
pos = 0; |
|||
while (bytesRead > 0) { |
|||
bytesRead = fs.readSync(fdr, _buff, 0, BUF_LENGTH, pos); |
|||
fs.writeSync(fdw, _buff, 0, bytesRead); |
|||
pos += bytesRead; |
|||
} |
|||
fs.closeSync(fdr); |
|||
return fs.closeSync(fdw); |
|||
}; |
|||
|
|||
copyFile = function(srcFile, destFile, cb) { |
|||
var fdr, fdw; |
|||
fdr = fs.createReadStream(srcFile); |
|||
fdw = fs.createWriteStream(destFile); |
|||
fdr.on('end', function() { |
|||
return cb(null); |
|||
}); |
|||
return fdr.pipe(fdw); |
|||
}; |
|||
|
|||
function copy(source, dest, callback) { |
|||
if (callback) |
|||
ncp(source, dest, callback); |
|||
else |
|||
ncp(source, dest, function(){}); |
|||
}; |
|||
|
|||
|
|||
module.exports.copyFileSync = copyFileSync; |
|||
module.exports.copyFile = copyFile; |
|||
module.exports.copy = copy; |
@ -0,0 +1,11 @@ |
|||
var fs = require('fs'); |
|||
|
|||
function touch(path, callback) { |
|||
fs.writeFile(path, '', callback); |
|||
} |
|||
|
|||
function touchSync(path) { |
|||
|
|||
} |
|||
|
|||
module.exports.touch = touch; |
@ -1,54 +1,45 @@ |
|||
// Generated by CoffeeScript 1.3.3
|
|||
(function() { |
|||
var copy, fs, fse, key, mkdir, path, read, remove, val; |
|||
|
|||
fs = require('fs'); |
|||
|
|||
path = require('path'); |
|||
|
|||
fse = {}; |
|||
|
|||
for (key in fs) { |
|||
val = fs[key]; |
|||
if (typeof val === 'function') { |
|||
fse[key] = val; |
|||
var fs = require('fs') |
|||
, path = require('path') |
|||
, jsonFile = require('jsonfile') |
|||
, fse = {}; |
|||
|
|||
for (var funcName in fs) { |
|||
var func = fs[funcName]; |
|||
if (fs.hasOwnProperty(funcName)) { |
|||
if (typeof func == 'function') |
|||
fse[funcName] = func; |
|||
} |
|||
} |
|||
|
|||
fs = fse; |
|||
|
|||
copy = require('./copy'); |
|||
|
|||
fs.copy = copy.copy; |
|||
|
|||
remove = require('./remove'); |
|||
|
|||
fs.remove = remove.remove; |
|||
|
|||
fs.removeSync = remove.removeSync; |
|||
|
|||
fs["delete"] = fs.remove; |
|||
|
|||
fs.deleteSync = fs.removeSync; |
|||
|
|||
mkdir = require('./mkdir'); |
|||
} |
|||
|
|||
fs.mkdir = mkdir.mkdir; |
|||
fs = fse; |
|||
|
|||
fs.mkdirSync = mkdir.mkdirSync; |
|||
fs.copy = require('./copy').copy; |
|||
|
|||
if (!(fs.exists != null)) { |
|||
fs.exists = path.exists; |
|||
} |
|||
var remove = require('./remove'); |
|||
fs.remove = remove.remove; |
|||
fs.removeSync = remove.removeSync; |
|||
fs['delete'] = fs.remove |
|||
fs.deleteSync = fs.removeSync |
|||
|
|||
if (!(fs.existsSync != null)) { |
|||
fs.existsSync = path.existsSync; |
|||
} |
|||
var mkdir = require('./mkdir') |
|||
fs.mkdir = mkdir.mkdir |
|||
fs.mkdirSync = mkdir.mkdirSync |
|||
|
|||
read = require('./read'); |
|||
fs.readJsonFile = jsonFile.readFile; |
|||
fs.readJSONFile = jsonFile.readFile; |
|||
fs.readJsonFileSync = jsonFile.readFileSync; |
|||
fs.readJSONFileSync = jsonFile.readFileSync; |
|||
|
|||
fs.readJSONFile = read.readJSONFile; |
|||
fs.writeJsonFile = jsonFile.writeFile; |
|||
fs.writeJSONFile = jsonFile.writeFile; |
|||
fs.writeJsonFileSync = jsonFile.writeFileSync; |
|||
fs.writeJSONFileSync = jsonFile.writeFileSync; |
|||
|
|||
module.exports = fs; |
|||
//make compatible for Node v0.8
|
|||
if (typeof fs.exists == 'undefined') |
|||
fs.exists = path.exists |
|||
if (typeof fs.existsSync == 'undefined') |
|||
fs.existsSync = path.existsSync |
|||
|
|||
}).call(this); |
|||
module.exports = fs |
|||
module.exports.jsonfile = jsonFile; //so users of fs-extra can modify jsonFile.spaces;
|
@ -1,24 +0,0 @@ |
|||
// Generated by CoffeeScript 1.3.3
|
|||
(function() { |
|||
var fs, readJSONFile; |
|||
|
|||
fs = require('fs'); |
|||
|
|||
readJSONFile = function(file, callback) { |
|||
return fs.readFile(file, function(err, data) { |
|||
var obj; |
|||
obj = {}; |
|||
try { |
|||
data = data.toString(); |
|||
obj = JSON.parse(data); |
|||
} catch (error) { |
|||
callback(error, null); |
|||
return; |
|||
} |
|||
return callback(null, obj); |
|||
}); |
|||
}; |
|||
|
|||
module.exports.readJSONFile = readJSONFile; |
|||
|
|||
}).call(this); |
@ -1,39 +1,17 @@ |
|||
// Generated by CoffeeScript 1.3.3
|
|||
(function() { |
|||
var fs, rimraf, rmrf, rmrfSync; |
|||
var rimraf = require('rimraf') |
|||
, fs = require('fs'); |
|||
|
|||
rimraf = require('rimraf'); |
|||
|
|||
fs = require('fs'); |
|||
|
|||
rmrfSync = function(dir) { |
|||
function rmrfSync(dir) { |
|||
return rimraf.sync(dir); |
|||
}; |
|||
} |
|||
|
|||
rmrf = function(dir, cb) { |
|||
function rmrf(dir, cb) { |
|||
if (cb != null) { |
|||
return rimraf(dir, cb); |
|||
return rimraf(dir, cb); |
|||
} else { |
|||
return rimraf(dir, (function() {})); |
|||
return rimraf(dir, (function() {})); |
|||
} |
|||
}; |
|||
|
|||
/* |
|||
remove = (path, callback) -> |
|||
fs.lstat path, (err, stats) -> |
|||
if stats.isDirectory() |
|||
rimraf(path, callback) |
|||
else |
|||
fs.unlink(path, callback) |
|||
*/ |
|||
|
|||
|
|||
module.exports.rmrfSync = rmrfSync; |
|||
|
|||
module.exports.rmrf = rmrf; |
|||
|
|||
module.exports.remove = rmrf; |
|||
|
|||
module.exports.removeSync = rmrfSync; |
|||
} |
|||
|
|||
}).call(this); |
|||
module.exports.remove = rmrf; |
|||
module.exports.removeSync = rmrfSync; |
|||
|
@ -1,31 +1,46 @@ |
|||
{ |
|||
"name" : "fs-extra", |
|||
"version" : "0.1.3", |
|||
"description" : "fs-extra contains methods that aren't included in the vanilla Node.js fs package.", |
|||
"homepage" : [ |
|||
"https://github.com/jprichardson/node-fs-extra" |
|||
], |
|||
"repository" : { |
|||
"type" : "git", |
|||
"url" : "https://github.com/jprichardson/node-fs-extra" |
|||
}, |
|||
"keywords" : ["fs","file","file system", "copy", "directory", "extra", "mkdirp", "recursive"], |
|||
"author" : "JP Richardson <jprichardson@gmail.com>", |
|||
"licenses" : [ { |
|||
"type" : "MIT", |
|||
"url" : "http://github.com/jprichardson/node-fs-extra/raw/master/LICENSE" |
|||
}], |
|||
"dependencies" : { |
|||
"rimraf": "1.0.x", |
|||
"ncp": "0.2.x", |
|||
"mkdirp": "0.3.x" |
|||
}, |
|||
"devDepdencies":{ |
|||
"mocha": "1.3.x", |
|||
"growl": "1.5.x", |
|||
"coffee-script": "1.3.x", |
|||
"test-util": "0.1.x", |
|||
"path-extra": "0.0.x" |
|||
}, |
|||
"main" : "./lib/index" |
|||
"name": "fs-extra", |
|||
"version": "0.2.0", |
|||
"description": "fs-extra contains methods that aren't included in the vanilla Node.js fs package.", |
|||
"homepage": [ |
|||
"https://github.com/jprichardson/node-fs-extra" |
|||
], |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "https://github.com/jprichardson/node-fs-extra" |
|||
}, |
|||
"keywords": [ |
|||
"fs", |
|||
"file", |
|||
"file system", |
|||
"copy", |
|||
"directory", |
|||
"extra", |
|||
"mkdirp", |
|||
"recursive" |
|||
], |
|||
"author": "JP Richardson <jprichardson@gmail.com>", |
|||
"licenses": [ |
|||
{ |
|||
"type": "MIT", |
|||
"url": "http://github.com/jprichardson/node-fs-extra/raw/master/LICENSE" |
|||
} |
|||
], |
|||
"dependencies": { |
|||
"rimraf": "1.0.x", |
|||
"ncp": "0.2.x", |
|||
"mkdirp": "0.3.x", |
|||
"jsonfile": "0.0.x" |
|||
}, |
|||
"devDepdencies": { |
|||
"mocha": "1.3.x", |
|||
"growl": "1.5.x", |
|||
"coffee-script": "1.3.x", |
|||
"test-util": "0.1.x", |
|||
"path-extra": "0.0.x" |
|||
}, |
|||
"main": "./lib/index", |
|||
"scripts": { |
|||
"test": "mocha test" |
|||
} |
|||
} |
|||
|
@ -1,32 +0,0 @@ |
|||
fs = require('fs') |
|||
ncp = require('ncp').ncp |
|||
|
|||
BUF_LENGTH = 64*1024 |
|||
_buff = new Buffer(BUF_LENGTH) |
|||
|
|||
copyFileSync = (srcFile, destFile) -> |
|||
fdr = fs.openSync(srcFile, 'r') |
|||
fdw = fs.openSync(destFile, 'w') |
|||
bytesRead = 1 |
|||
pos = 0 |
|||
while bytesRead > 0 |
|||
bytesRead = fs.readSync(fdr, _buff, 0, BUF_LENGTH, pos) |
|||
fs.writeSync(fdw,_buff,0,bytesRead) |
|||
pos += bytesRead |
|||
fs.closeSync(fdr) |
|||
fs.closeSync(fdw) |
|||
|
|||
copyFile = (srcFile, destFile, cb) -> |
|||
fdr = fs.createReadStream(srcFile) |
|||
fdw = fs.createWriteStream(destFile) |
|||
fdr.on 'end', -> |
|||
cb(null) |
|||
fdr.pipe(fdw) |
|||
|
|||
|
|||
copy = (source, dest, callback) -> |
|||
ncp(source, dest, callback) |
|||
|
|||
module.exports.copyFileSync = copyFileSync |
|||
module.exports.copyFile = copyFile |
|||
module.exports.copy = copy |
@ -1,35 +0,0 @@ |
|||
fs = require('fs') |
|||
path = require('path') |
|||
|
|||
fse = {} |
|||
|
|||
for key,val of fs |
|||
if typeof val is 'function' |
|||
fse[key] = val |
|||
|
|||
fs = fse |
|||
|
|||
#fs-extra |
|||
copy = require('./copy') |
|||
fs.copy = copy.copy |
|||
|
|||
remove = require('./remove') |
|||
fs.remove = remove.remove |
|||
fs.removeSync = remove.removeSync |
|||
fs.delete = fs.remove |
|||
fs.deleteSync = fs.removeSync |
|||
|
|||
mkdir = require('./mkdir') |
|||
fs.mkdir = mkdir.mkdir |
|||
fs.mkdirSync = mkdir.mkdirSync |
|||
|
|||
#make compatible for Node v0.8 |
|||
if not fs.exists? |
|||
fs.exists = path.exists |
|||
if not fs.existsSync? |
|||
fs.existsSync = path.existsSync |
|||
|
|||
read = require('./read') |
|||
fs.readJSONFile = read.readJSONFile |
|||
|
|||
module.exports = fs |
@ -1,4 +0,0 @@ |
|||
mkdirp = require('mkdirp') |
|||
|
|||
module.exports.mkdir = mkdirp |
|||
module.exports.mkdirSync = mkdirp.sync |
@ -1,13 +0,0 @@ |
|||
fs = require('fs') |
|||
|
|||
readJSONFile = (file, callback) -> |
|||
fs.readFile file, (err, data) -> |
|||
obj = {} |
|||
try |
|||
data = data.toString() |
|||
obj = JSON.parse(data) |
|||
catch error |
|||
callback(error, null); return |
|||
callback(null, obj) |
|||
|
|||
module.exports.readJSONFile = readJSONFile |
@ -1,25 +0,0 @@ |
|||
rimraf = require('rimraf') |
|||
fs = require('fs') |
|||
|
|||
rmrfSync = (dir) -> |
|||
rimraf.sync(dir) |
|||
|
|||
rmrf = (dir,cb) -> |
|||
if cb? |
|||
rimraf(dir,cb) |
|||
else #rimraf throughs an error without a callback |
|||
rimraf(dir, (->)) |
|||
|
|||
### |
|||
remove = (path, callback) -> |
|||
fs.lstat path, (err, stats) -> |
|||
if stats.isDirectory() |
|||
rimraf(path, callback) |
|||
else |
|||
fs.unlink(path, callback) |
|||
### |
|||
|
|||
module.exports.rmrfSync = rmrfSync |
|||
module.exports.rmrf = rmrf |
|||
module.exports.remove = rmrf |
|||
module.exports.removeSync = rmrfSync |
Loading…
Reference in new issue