heroku-source-deployer
Advanced tools
Comparing version 0.0.3 to 0.0.4
{ | ||
"name": "heroku-source-deployer", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Deploys sources to Heroku", | ||
@@ -39,3 +39,4 @@ "main": "plugin.js", | ||
"mocha": "~2.3.3", | ||
"mocha-spec-reporter-async": "~0.5.7" | ||
"mocha-spec-reporter-async": "~0.5.7", | ||
"tmp": "~0.0.28" | ||
}, | ||
@@ -42,0 +43,0 @@ "scripts": { |
@@ -43,3 +43,5 @@ 'use strict'; | ||
options.ignore = function(name) { | ||
return gitignore.denies(name); | ||
// name could be absolute but we need a relative name since .gitignore is relative | ||
var relativeName = path.relative(dir, name); | ||
return gitignore.denies(relativeName); | ||
}; | ||
@@ -46,0 +48,0 @@ } |
@@ -8,3 +8,5 @@ 'use strict'; | ||
var Promise = require('bluebird'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var herokuSourceDeployer = require('../'); | ||
@@ -29,8 +31,51 @@ | ||
it('dirToTarGz should create a tar.gz and apply the .gitignore', function() { | ||
return assert.eventually.isBelow(herokuSourceDeployer.dirToTarGz('.').then(function(d) {return d.length;}), 5000000); | ||
function dirToTarGzTest(dir) { | ||
var tmp = require('tmp'); | ||
var tmpDir = tmp.dirSync().name; | ||
var untgzPromise = herokuSourceDeployer.dirToTarGz(dir).then(function(data) { | ||
return new Promise(function(resolve, reject) { | ||
var zlib = require('zlib'); | ||
var tar = require('tar-fs'); | ||
var stream = require('stream'); | ||
var bufferStream = new stream.PassThrough(); | ||
bufferStream.end(data); | ||
var write = bufferStream.pipe(zlib.createGunzip()).pipe(tar.extract(tmpDir)); | ||
write.on('error', reject); | ||
write.on('finish', resolve); | ||
}); | ||
}); | ||
var gitIgnoreCheckPromise = untgzPromise.then(function() { | ||
return new Promise(function(resolve, reject) { | ||
var nodeModulesExists = fs.existsSync(path.join(tmpDir, "node_modules", "tar-fs")); | ||
var testAppIndexPhpExists = fs.existsSync(path.join(tmpDir, "test", "app", "index.php")); | ||
if (!nodeModulesExists && testAppIndexPhpExists) { | ||
resolve("The .gitignore was applied correctly"); | ||
} | ||
else { | ||
reject("The .gitignore was not applied correctly"); | ||
} | ||
}); | ||
}); | ||
return assert.isFulfilled(gitIgnoreCheckPromise); | ||
} | ||
it('dirToTarGz should create a tar.gz from a relative path and apply the .gitignore', function() { | ||
this.timeout(10000); | ||
return dirToTarGzTest("."); | ||
}); | ||
it('dirToTarGz should create a tar.gz from an absolute path and apply the .gitignore', function() { | ||
this.timeout(10000); | ||
return dirToTarGzTest(path.resolve(".")); | ||
}); | ||
it('deploy should fail when the dir does not exist', function() { | ||
return assert.isRejected(herokuSourceDeployer.deployDir(apiToken, 'foo', 'foo'), /no such file or directory, stat 'foo'/); | ||
return assert.isRejected(herokuSourceDeployer.deployDir(apiToken, 'foo', 'foo'), /stat 'foo'/); | ||
}); | ||
@@ -37,0 +82,0 @@ |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
9394
8
202
1
26
7