-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented an 'afterExtract' function hook RE: #270
- Loading branch information
1 parent
b51a405
commit 795230c
Showing
4 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
'use strict' | ||
|
||
var config = require('./config.json') | ||
var fs = require('fs') | ||
var packager = require('..') | ||
var path = require('path') | ||
var series = require('run-series') | ||
var test = require('tape') | ||
var util = require('./util') | ||
var waterfall = require('run-waterfall') | ||
|
||
function verifyPackageExistence (finalPaths, callback) { | ||
series(finalPaths.map(function (finalPath) { | ||
return function (cb) { | ||
fs.stat(finalPath, cb) | ||
} | ||
}), function (err, statsResults) { | ||
if (err) return callback(null, false) | ||
|
||
callback(null, statsResults.every(function (stats) { | ||
return stats.isDirectory() | ||
})) | ||
}) | ||
} | ||
|
||
util.setup() | ||
test('platform=all test (one arch) (afterExtract hook)', function (t) { | ||
t.timeoutAfter(config.timeout * 2) // 2 packages will be built during this test | ||
|
||
var afterExtractCalled = false | ||
var opts = { | ||
name: 'basicTest', | ||
dir: path.join(__dirname, 'fixtures', 'basic'), | ||
version: config.version, | ||
arch: 'ia32', | ||
platform: 'all', | ||
afterExtract: [function testAfterExtract (buildPath, electronVersion, platform, arch, callback) { | ||
afterExtractCalled = true | ||
t.equal(electronVersion, opts.version, 'afterExtract electronVersion should be the same as the options object') | ||
t.equal(arch, opts.arch, 'afterExtract arch should be the same as the options object') | ||
callback() | ||
}] | ||
} | ||
|
||
waterfall([ | ||
function (cb) { | ||
packager(opts, cb) | ||
}, function (finalPaths, cb) { | ||
t.equal(finalPaths.length, 2, 'packager call should resolve with expected number of paths') | ||
t.true(afterExtractCalled, 'afterExtract methods should have been called') | ||
verifyPackageExistence(finalPaths, cb) | ||
}, function (exists, cb) { | ||
t.true(exists, 'Packages should be generated for both 32-bit platforms') | ||
cb() | ||
} | ||
], function (err) { | ||
t.end(err) | ||
}) | ||
}) | ||
util.teardown() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters