Skip to content

Commit 3ede220

Browse files
committed
first commit
0 parents  commit 3ede220

14 files changed

+205
-0
lines changed

.editorconfig

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false
14+
15+
[Makefile]
16+
indent_style = tab

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
coverage

.jshintrc

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"expr": true,
3+
"eqeqeq": true,
4+
"eqnull": true,
5+
"indent": 2,
6+
"latedef": "nofunc",
7+
"newcap": true,
8+
"quotmark": true,
9+
"trailing": true,
10+
"undef": true,
11+
"unused": true,
12+
"lastsemic": true,
13+
"boss": true,
14+
"funcscope": true,
15+
"loopfunc": true,
16+
"smarttabs": true,
17+
"sub": true,
18+
"strict": true,
19+
"node": true,
20+
"globals": {
21+
"describe": false,
22+
"xdescribe": false,
23+
"it": false,
24+
"xit": false,
25+
"before": false,
26+
"beforeEach": false,
27+
"after": false,
28+
"afterEach": false,
29+
"define": false
30+
}
31+
}

.npmignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
test/
2+
docs/
3+
.npmignore
4+
.editorconfig
5+
.travis.yml
6+
.jshintrc

.travis.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: node_js
2+
3+
node_js:
4+
- "0.10"
5+
6+
after_success: make coveralls

HISTORY.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# History
2+
3+
---
4+
5+
## 0.1.0
6+
7+
First commit

Makefile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
test:
2+
./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- -R spec -t 20000
3+
4+
coveralls: test
5+
cat ./coverage/lcov.info | ./node_modules/.bin/coveralls
6+
7+
debug:
8+
node $(NODE_DEBUG) ./node_modules/.bin/_mocha -R spec -t 20000
9+
10+
.PHONY: test

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# gulp-scp2 [![Build Status](https://travis-ci.org/popomore/gulp-scp2.png?branch=master)](https://travis-ci.org/popomore/gulp-scp2) [![Coverage Status](https://coveralls.io/repos/popomore/gulp-scp2/badge.png?branch=master)](https://coveralls.io/r/popomore/gulp-scp2?branch=master)
2+
3+
The best module ever.
4+
5+
---
6+
7+
## Install
8+
9+
```
10+
$ npm install gulp-scp2 -g
11+
```
12+
13+
## Usage
14+
15+
```
16+
var gulp-scp2 = require('gulp-scp2');
17+
```
18+
19+
## LISENCE
20+
21+
Copyright (c) 2014 popomore. Licensed under the MIT license.

examples/assets/a.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('a.js');

examples/assets/b.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('中文');

examples/test.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var gulp = require('gulp');
2+
var scp = require('..');
3+
4+
gulp.src('*.js', {cwd: __dirname + '/assets'})
5+
.pipe(scp({
6+
host: 'localhost',
7+
username: 'username',
8+
password: 'password',
9+
dest: '/home/username/'
10+
}));

index.js

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
'use strict';
2+
3+
var path = require('path');
4+
var join = path.join;
5+
var dirname = path.dirname;
6+
var Client = require('scp2').Client;
7+
var through = require('through2');
8+
var debug = require('debug')('gulp-scp2');
9+
var PluginError = require('gulp-util').PluginError;
10+
11+
module.exports = function(options) {
12+
options || (options = {});
13+
options.host = options.host || 'localhost';
14+
options.username = options.username || 'admin';
15+
options.dest = options.dest || '/home/' + options.username;
16+
17+
var client = createClient(options);
18+
19+
return through.obj(function transform(file, enc, callback) {
20+
if (file.isStream()) return callback(new PluginError('gulp-scp2', 'Streaming not supported.'));
21+
22+
var path = join(options.dest, file.relative);
23+
client.mkdir(dirname(path), function() {
24+
client.write({
25+
destination: path,
26+
content: file.contents
27+
}, callback);
28+
});
29+
}, function flush(callback) {
30+
client.close();
31+
callback();
32+
});
33+
};
34+
35+
function createClient(options) {
36+
var client = new Client(options);
37+
client.on('connect', function() {
38+
debug('ssh connect %s', options.host);
39+
});
40+
client.on('close', function() {
41+
debug('ssh connect %s', options.host);
42+
});
43+
client.on('mkdir', function(dir) {
44+
debug('mkdir %s', dir);
45+
});
46+
client.on('write', function(o) {
47+
debug('write %s', o.destination);
48+
});
49+
client.on('error', function(err) {
50+
debug('error %s', err);
51+
});
52+
return client;
53+
}

package.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "gulp-scp2",
3+
"version": "0.1.0",
4+
"description": "The best module ever.",
5+
"main": "index",
6+
"dependencies": {
7+
"debug": "~0.8.1",
8+
"gulp": "~3.6.2",
9+
"gulp-util": "~2.2.14",
10+
"scp2": "~0.1.4",
11+
"through2": "~0.4.2"
12+
},
13+
"devDependencies": {
14+
"coveralls": "~2.10.0",
15+
"istanbul": "~0.2.7",
16+
"mocha": "~1.18.2",
17+
"should": "~3.3.1"
18+
},
19+
"repository": {
20+
"type": "git",
21+
"url": "https://github.com/popomore/gulp-scp2"
22+
},
23+
"homepage": "https://github.com/popomore/gulp-scp2",
24+
"author": "popomore <[email protected]>",
25+
"license": "MIT",
26+
"scripts": {
27+
"test": "make test"
28+
}
29+
}

test/index.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
3+
var should = require('should');
4+
var gulp-scp2 = require('..');
5+
6+
describe('gulp-scp2', function() {
7+
8+
it('Normal use', function() {
9+
10+
});
11+
12+
});

0 commit comments

Comments
 (0)