New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

grunt-git-deploy

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-git-deploy - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

test/fixtures/first/.hidden-file

60

Gruntfile.js

@@ -25,9 +25,33 @@ /*

function git(args) {
return function(cb) {
grunt.log.writeln('Running ' + args.join(' ').green + ' in ' + dest );
grunt.util.spawn({
cmd: 'git',
args: args,
opts: {cwd: dest}
}, cb);
};
}
function touch(args) {
return function(cb) {
grunt.util.spawn({
cmd: 'touch',
args: args,
opts: {cwd: dest}
}, cb);
};
}
var done = this.async();
grunt.util.spawn({
cmd: 'git',
args: ['init'],
opts: {cwd: dest}
}, done);
grunt.util.async.series([
git(['init']),
git(['checkout', '-b', 'gh-pages']),
touch(['readme.md']),
git(['add', '--all']),
git(['commit', '--message=Initial commit']),
git(['checkout', '-b', 'master'])
], done);
});

@@ -40,3 +64,5 @@

clean: {
tests: ['tmp']
tests: ['tmp'],
test_build: ['tmp/src'],
deploy: ['tmp/grunt-git-deploy']
},

@@ -55,3 +81,4 @@

src: '**/**',
dest: 'tmp/src/'
dest: 'tmp/src/',
dot: true
},

@@ -62,4 +89,5 @@ second: {

src: '**/**',
dest: 'tmp/src/'
},
dest: 'tmp/src/',
dot: true
}
},

@@ -69,7 +97,15 @@

git_deploy: {
default_options: {
first: {
options: {
url: '../repo'
url: '../repo',
message: 'first deploy'
},
src: 'tmp/src'
},
second: {
options: {
url: '../repo',
message: 'second deploy'
},
src: 'tmp/src'
}

@@ -95,3 +131,3 @@ },

// plugin's task(s), then test the result.
grunt.registerTask('test', ['clean', 'init_repo', 'copy:first', 'git_deploy', 'copy:second', 'git_deploy', 'nodeunit']);
grunt.registerTask('test', ['clean', 'init_repo', 'copy:first', 'git_deploy:first', 'clean:deploy', 'clean:test_build', 'copy:second', 'git_deploy:second', 'nodeunit']);

@@ -98,0 +134,0 @@ // By default, run all tests.

7

package.json
{
"name": "grunt-git-deploy",
"description": "Deploy files to any branch of any remote git repository.",
"version": "0.1.1",
"version": "0.2.0",
"homepage": "https://github.com/iclanzan/grunt-git-deploy",

@@ -32,6 +32,7 @@ "author": {

"devDependencies": {
"grunt": "~0.4.1",
"grunt-cli": "0.1.13",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-nodeunit": "~0.1.2",
"grunt": "~0.4.1"
"grunt-contrib-nodeunit": "^0.4.1"
},

@@ -38,0 +39,0 @@ "peerDependencies": {

@@ -24,2 +24,5 @@ /*

var pkg = grunt.file.readJSON('package.json');
if (!options.url) {

@@ -31,2 +34,3 @@ grunt.fail.warn('The URL to a remote git repository is required.');

var src = this.filesSrc[0];
var deployDir = 'tmp/' + pkg.name;

@@ -40,7 +44,7 @@ if (!file.isDir(src)) {

return function(cb) {
grunt.log.writeln('Running ' + args.join(' ').green);
grunt.log.writeln('Running ' + args.join(' ').green + ' in ' + deployDir );
spawn({
cmd: 'git',
args: args,
opts: {cwd: src}
opts: {cwd: deployDir}
}, cb);

@@ -50,2 +54,45 @@ };

function copyIntoRepo( srcDir, destDir ){
return function(cb) {
grunt.log.writeln('Copying ' + srcDir + ' to ' + destDir );
//Ensure directory has trailingslash
if ( srcDir.substr(-1) != '/' ) {
srcDir = srcDir + '/';
}
grunt.file.expand( { 'expand': true, 'cwd' : destDir, dot: true }, ['**/*', '!.git/**'] ).forEach( function( dest ){
if (process.platform === 'win32') {
dest = path.join(destDir, dest).replace(/\\/g, '/');
} else {
dest = path.join(destDir, dest);
}
grunt.file.delete(dest);
});
grunt.file.expand( { 'expand': true, 'cwd' : srcDir, dot: true }, ['**/*', '!.git/**'] ).forEach( function( src ){
var dest;
if (process.platform === 'win32') {
dest = path.join(destDir, src).replace(/\\/g, '/');
} else {
dest = path.join(destDir, src);
}
if ( grunt.file.isDir(srcDir + src) ) {
grunt.file.mkdir(dest);
} else {
grunt.file.copy(srcDir + src, dest);
}
});
cb();
};
}
grunt.file.mkdir( deployDir );
grunt.file.delete(path.join(src, '.git'));

@@ -56,7 +103,8 @@

grunt.util.async.series([
git(['init']),
git(['checkout', '--orphan', options.branch]),
git(['clone', '-b', options.branch, options.url, '.' ]),
git(['checkout', '-B', options.branch]),
copyIntoRepo( src, deployDir ),
git(['add', '--all']),
git(['commit', '--message="' + options.message + '"']),
git(['push', '--prune', '--force', '--quiet', options.url, options.branch])
git(['commit', '--message=' + options.message]),
git(['push', '--prune', '--quiet', options.url, options.branch])
], done);

@@ -63,0 +111,0 @@

@@ -35,3 +35,3 @@ 'use strict';

default_options: function(test) {
test.expect(3);
test.expect(7);

@@ -43,4 +43,17 @@ grunt.file.recurse('test/fixtures/second', function(abs, root, subdir, file) {

test.done();
test.ok(!grunt.file.exists(path.join('tmp/repo', 'to-be-removed')), 'The file ‘to-be-removed’ should have been removed from the repository.');
grunt.util.spawn({
cmd: 'git',
args: ['log', '--format=%s'],
opts: {cwd: 'tmp/repo'}
}, function( a, b, c ){
//Get repo history
var expected = "second deploy\nfirst deploy\nInitial commit";
test.equal( b.stdout, expected, 'The deployment repository`s history is not as expected' )
test.done();
} );
}
};

Sorry, the diff of this file is not supported yet

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