fix
This commit is contained in:
1
book/node_modules/cp/.npmignore
generated
vendored
Normal file
1
book/node_modules/cp/.npmignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
test
|
5
book/node_modules/cp/.travis.yml
generated
vendored
Normal file
5
book/node_modules/cp/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
- "0.11"
|
||||
script: "make test"
|
22
book/node_modules/cp/History.md
generated
vendored
Normal file
22
book/node_modules/cp/History.md
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
0.2.0 / 2014-11-14
|
||||
==================
|
||||
|
||||
* .travis: Remove node 0.8
|
||||
* index: Add `yield cp(src, dst)` support (closes #4)
|
||||
* Readme: Rename to match conventions
|
||||
* Readme: Add `yield` dox
|
||||
* History: Rename/rewrite to match conventions
|
||||
* Makefile: Refactor to use istanbul for coverage
|
||||
* Add travis
|
||||
|
||||
0.1.1 / 2013-07-08
|
||||
==================
|
||||
|
||||
* added test-coverage reporting
|
||||
* explicitly destroying streams to prevent erroneously leaving one open on error
|
||||
|
||||
0.1.0 / 2013-07-01
|
||||
==================
|
||||
|
||||
* initial release, support `cp(src, dest, cb)` and `cp.sync(src, dest)`
|
28
book/node_modules/cp/Makefile
generated
vendored
Normal file
28
book/node_modules/cp/Makefile
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
BIN := node_modules/.bin
|
||||
NODE ?= node
|
||||
SRC = $(wildcard *.js)
|
||||
TEST = $(wildcard test/*.js)
|
||||
|
||||
test: NODE=$(BIN)/gnode
|
||||
test: node_modules
|
||||
$(NODE) $(BIN)/_mocha \
|
||||
--reporter spec \
|
||||
--require co-mocha \
|
||||
$(NODE_FLAGS)
|
||||
|
||||
# coverage only available on 0.11
|
||||
coverage: node_modules $(SRC) $(TEST)
|
||||
$(NODE) --harmony-generators $(BIN)/istanbul cover \
|
||||
$(BIN)/_mocha -- \
|
||||
--require co-mocha \
|
||||
--reporter spec
|
||||
|
||||
node_modules: package.json
|
||||
@npm install
|
||||
@touch $@
|
||||
|
||||
clean:
|
||||
@rm -rf coverage test/fixtures/*copy*
|
||||
|
||||
.PHONY: test clean
|
41
book/node_modules/cp/Readme.md
generated
vendored
Normal file
41
book/node_modules/cp/Readme.md
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
# cp
|
||||
|
||||
`cp` for node
|
||||
|
||||
Really simple, straight-forward copying of files.
|
||||
|
||||
## API
|
||||
|
||||
### `cp(src, dest, cb)` / `yield cp(src, dest)`
|
||||
|
||||
Copy file `src` to `dest`
|
||||
|
||||
### `cp.sync(src, dest)`
|
||||
|
||||
Synchronously copy file `src` to `dest`
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2013 Stephen Mathieson <me@stephenmathieson.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
92
book/node_modules/cp/index.js
generated
vendored
Normal file
92
book/node_modules/cp/index.js
generated
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var fs = require('fs');
|
||||
try { fs = require('graceful-fs'); } catch (e) {}
|
||||
|
||||
/**
|
||||
* Magic number.
|
||||
*/
|
||||
|
||||
var MAX_BUFFER = 1024;
|
||||
|
||||
/**
|
||||
* Export `cp`.
|
||||
*/
|
||||
|
||||
exports = module.exports = cp;
|
||||
|
||||
/**
|
||||
* Export `sync`.
|
||||
*/
|
||||
|
||||
exports.sync = sync;
|
||||
|
||||
/**
|
||||
* Copy `src` to `dest`, invoking `cb(err)` when done.
|
||||
*
|
||||
* @param {String} src
|
||||
* @param {String} dest
|
||||
* @param {Function} [cb]
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function cp(src, dest, cb) {
|
||||
// yield support
|
||||
if ('function' != typeof cb) return thunk;
|
||||
|
||||
var complete = false;
|
||||
var read = fs.createReadStream(src);
|
||||
var write = fs.createWriteStream(dest);
|
||||
|
||||
write.on('error', done);
|
||||
write.on('close', done);
|
||||
read.on('error', done);
|
||||
read.pipe(write);
|
||||
|
||||
// done callback
|
||||
function done(err) {
|
||||
if (!complete) {
|
||||
complete = true;
|
||||
read.destroy();
|
||||
write.destroy();
|
||||
cb(err);
|
||||
}
|
||||
}
|
||||
|
||||
// thunk-ified
|
||||
function thunk(done) {
|
||||
cp(src, dest, done);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronously copy file `src` to `dest`
|
||||
*
|
||||
* @param {String} src
|
||||
* @param {String} dest
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function sync(src, dest) {
|
||||
if (!fs.existsSync(src)) {
|
||||
throw new Error('no such file or directory: ' + src);
|
||||
}
|
||||
|
||||
var buffer = new Buffer(MAX_BUFFER);
|
||||
var bytesRead = MAX_BUFFER;
|
||||
var pos = 0;
|
||||
var read = fs.openSync(src, 'r');
|
||||
var write = fs.openSync(dest, 'w');
|
||||
|
||||
while (MAX_BUFFER == bytesRead) {
|
||||
bytesRead = fs.readSync(read, buffer, 0, MAX_BUFFER, pos);
|
||||
fs.writeSync(write, buffer, 0, bytesRead);
|
||||
pos += bytesRead;
|
||||
}
|
||||
|
||||
fs.closeSync(read);
|
||||
fs.closeSync(write);
|
||||
}
|
33
book/node_modules/cp/package.json
generated
vendored
Normal file
33
book/node_modules/cp/package.json
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "cp",
|
||||
"version": "0.2.0",
|
||||
"description": "cp for node",
|
||||
"keywords": [
|
||||
"fs",
|
||||
"copy",
|
||||
"cp"
|
||||
],
|
||||
"author": "Stephen Mathieson <me@stephenmathieson.com>",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/stephenmathieson/node-cp.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"co-mocha": "^1.0.3",
|
||||
"glob": "~3.2.1",
|
||||
"gnode": "^0.1.0",
|
||||
"istanbul": "git://github.com/gotwarlost/istanbul#c6f8fc8b102cfa4e4455d6a165485b38cb58160c",
|
||||
"mocha": "^2.0.1"
|
||||
},
|
||||
"main": "index",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/stephenmathieson/node-cp/issues"
|
||||
},
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user