grunt-git-deploy
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -13,2 +13,23 @@ /* | ||
grunt.registerMultiTask('init_repo', 'Initialize a git repository in a directory.', function() { | ||
var dest = this.files[0].dest; | ||
if (!grunt.file.exists(dest)) { | ||
grunt.file.mkdir(dest); | ||
} | ||
else if (!grunt.file.isDir(dest)) { | ||
grunt.fail.warn('A source directory is needed.'); | ||
return false; | ||
} | ||
var done = this.async(); | ||
grunt.util.spawn({ | ||
cmd: 'git', | ||
args: ['init'], | ||
opts: {cwd: dest} | ||
}, done); | ||
}); | ||
// Project configuration. | ||
@@ -22,2 +43,23 @@ grunt.initConfig({ | ||
init_repo: { | ||
main: { | ||
dest: 'tmp/repo' | ||
} | ||
}, | ||
copy: { | ||
first: { | ||
expand: true, | ||
cwd: 'test/fixtures/first', | ||
src: '**/**', | ||
dest: 'tmp/src/' | ||
}, | ||
second: { | ||
expand: true, | ||
cwd: 'test/fixtures/second', | ||
src: '**/**', | ||
dest: 'tmp/src/' | ||
}, | ||
}, | ||
// Configuration to be run (and then tested). | ||
@@ -27,5 +69,5 @@ git_deploy: { | ||
options: { | ||
url: 'tmp/repo' | ||
url: '../repo' | ||
}, | ||
src: 'test/fixtures' | ||
src: 'tmp/src' | ||
} | ||
@@ -46,2 +88,3 @@ }, | ||
grunt.loadNpmTasks('grunt-contrib-clean'); | ||
grunt.loadNpmTasks('grunt-contrib-copy'); | ||
grunt.loadNpmTasks('grunt-contrib-nodeunit'); | ||
@@ -51,3 +94,3 @@ | ||
// plugin's task(s), then test the result. | ||
grunt.registerTask('test', ['clean', 'git_deploy', 'nodeunit']); | ||
grunt.registerTask('test', ['clean', 'init_repo', 'copy:first', 'git_deploy', 'copy:second', 'git_deploy', 'nodeunit']); | ||
@@ -54,0 +97,0 @@ // By default, run all tests. |
{ | ||
"name": "grunt-git-deploy", | ||
"description": "Deploy files to any branch of any remote git repository.", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"homepage": "https://github.com/iclanzan/grunt-git-deploy", | ||
@@ -33,2 +33,3 @@ "author": { | ||
"grunt-contrib-clean": "~0.4.0", | ||
"grunt-contrib-copy": "~0.4.1", | ||
"grunt-contrib-nodeunit": "~0.1.2", | ||
@@ -35,0 +36,0 @@ "grunt": "~0.4.1" |
@@ -11,2 +11,4 @@ /* | ||
var path = require("path"); | ||
module.exports = function(grunt) { | ||
@@ -46,2 +48,4 @@ var file = grunt.file; | ||
grunt.file.delete(path.join(src, '.git')); | ||
var done = this.async(); | ||
@@ -48,0 +52,0 @@ |
'use strict'; | ||
var grunt = require('grunt'); | ||
var path = require('path'); | ||
@@ -27,23 +28,18 @@ /* | ||
setUp: function(done) { | ||
// setup here if necessary | ||
done(); | ||
grunt.util.spawn({ | ||
cmd: 'git', | ||
args: ['checkout', 'gh-pages'], | ||
opts: {cwd: 'tmp/repo'} | ||
}, done); | ||
}, | ||
default_options: function(test) { | ||
test.expect(1); | ||
test.expect(3); | ||
var actual = grunt.file.read('tmp/default_options'); | ||
var expected = grunt.file.read('test/expected/default_options'); | ||
test.equal(actual, expected, 'should describe what the default behavior is.'); | ||
grunt.file.recurse('test/fixtures/second', function(abs, root, subdir, file) { | ||
var relativePath = path.join(subdir || '', file); | ||
test.ok(grunt.file.exists(path.join('tmp/repo', relativePath)), 'The file ‘' + relativePath + '’ should have been copied into the repository.'); | ||
}); | ||
test.done(); | ||
}, | ||
custom_options: function(test) { | ||
test.expect(1); | ||
var actual = grunt.file.read('tmp/custom_options'); | ||
var expected = grunt.file.read('test/expected/custom_options'); | ||
test.equal(actual, expected, 'should describe what the custom option(s) behavior is.'); | ||
test.done(); | ||
} | ||
}; |
Sorry, the diff of this file is not supported yet
8581
12
162
4