Skip to content

Commit

Permalink
Remove duplicate isPlatformMac function
Browse files Browse the repository at this point in the history
  • Loading branch information
malept committed Apr 10, 2016
1 parent a6a7acd commit a7334db
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
4 changes: 4 additions & 0 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ module.exports = {
archs: archs,
platforms: platforms,

isPlatformMac: function isPlatformMac (platform) {
return platform === 'darwin' || platform === 'mas'
},

generateFinalBasename: generateFinalBasename,
generateFinalPath: generateFinalPath,

Expand Down
8 changes: 2 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ var supportedPlatforms = {
win32: './win32'
}

function isPlatformMac (platform) {
return platform === 'darwin' || platform === 'mas'
}

function validateList (list, supported, name) {
// Validates list of architectures or platforms.
// Returns a normalized array if successful, or an error message string otherwise.
Expand Down Expand Up @@ -94,7 +90,7 @@ function createSeries (opts, archs, platforms) {
archs.forEach(function (arch) {
platforms.forEach(function (platform) {
// Electron does not have 32-bit releases for Mac OS X, so skip that combination
if (isPlatformMac(platform) && arch === 'ia32') return
if (common.isPlatformMac(platform) && arch === 'ia32') return
combinations.push({
platform: platform,
arch: arch,
Expand Down Expand Up @@ -171,7 +167,7 @@ function createSeries (opts, archs, platforms) {
})
}

if (isPlatformMac(combination.platform)) {
if (common.isPlatformMac(combination.platform)) {
testSymlink(function (result) {
if (result) return checkOverwrite()

Expand Down
6 changes: 3 additions & 3 deletions test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function generateNamePath (opts) {
// Generates path to verify reflects the name given in the options.
// Returns the Helper.app location on darwin since the top-level .app is already tested for the resources path;
// returns the executable for other OSes
if (util.isPlatformMac(opts.platform)) {
if (common.isPlatformMac(opts.platform)) {
return path.join(opts.name + '.app', 'Contents', 'Frameworks', opts.name + ' Helper.app')
}

Expand Down Expand Up @@ -45,7 +45,7 @@ function createDefaultsTest (opts) {
resourcesPath = path.join(finalPath, util.generateResourcesPath(opts))
fs.stat(path.join(finalPath, generateNamePath(opts)), cb)
}, function (stats, cb) {
if (util.isPlatformMac(opts.platform)) {
if (common.isPlatformMac(opts.platform)) {
t.true(stats.isDirectory(), 'The Helper.app should reflect opts.name')
} else {
t.true(stats.isFile(), 'The executable should reflect opts.name')
Expand Down Expand Up @@ -317,7 +317,7 @@ function createInferTest (opts) {
opts.name = packageJSON.productName
fs.stat(path.join(finalPath, generateNamePath(opts)), cb)
}, function (stats, cb) {
if (util.isPlatformMac(opts.platform)) {
if (common.isPlatformMac(opts.platform)) {
t.true(stats.isDirectory(), 'The Helper.app should reflect productName')
} else {
t.true(stats.isFile(), 'The executable should reflect productName')
Expand Down
10 changes: 2 additions & 8 deletions test/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,13 @@ var version = require('./config.json').version
var ORIGINAL_CWD = process.cwd()
var WORK_CWD = path.join(__dirname, 'work')

function isPlatformMac (platform) {
return platform === 'darwin' || platform === 'mas'
}

var combinations = []
common.archs.forEach(function (arch) {
common.platforms.forEach(function (platform) {
// Electron does not have 32-bit releases for Mac OS X, so skip that combination
// Also skip testing darwin/mas target on Windows since electron-packager itself skips it
// (see https://github.com/electron-userland/electron-packager/issues/71)
if (isPlatformMac(platform) && (arch === 'ia32' || require('os').platform() === 'win32')) return
if (common.isPlatformMac(platform) && (arch === 'ia32' || require('os').platform() === 'win32')) return

combinations.push({
arch: arch,
Expand Down Expand Up @@ -58,7 +54,7 @@ exports.forEachCombination = function forEachCombination (cb) {
}

exports.generateResourcesPath = function generateResourcesPath (opts) {
return isPlatformMac(opts.platform)
return common.isPlatformMac(opts.platform)
? path.join(opts.name + '.app', 'Contents', 'Resources')
: 'resources'
}
Expand All @@ -67,8 +63,6 @@ exports.getWorkCwd = function getWorkCwd () {
return WORK_CWD
}

exports.isPlatformMac = isPlatformMac

// tape doesn't seem to have a provision for before/beforeEach/afterEach/after,
// so run setup/teardown and cleanup tasks as additional "tests" to put them in sequence
// and run them irrespective of test failures
Expand Down

0 comments on commit a7334db

Please sign in to comment.