pulsar/script/config.js

63 lines
1.9 KiB
JavaScript
Raw Normal View History

// This module exports paths, names, and other metadata that is referenced
// throughout the build.
'use strict'
2016-08-02 15:04:45 +03:00
const fs = require('fs')
const path = require('path')
const repositoryRootPath = path.resolve(__dirname, '..')
2016-08-02 15:04:45 +03:00
const apmRootPath = path.join(repositoryRootPath, 'apm')
const scriptRootPath = path.join(repositoryRootPath, 'script')
const buildOutputPath = path.join(repositoryRootPath, 'out')
const docsOutputPath = path.join(repositoryRootPath, 'docs', 'output')
const intermediateAppPath = path.join(buildOutputPath, 'app')
const symbolsPath = path.join(buildOutputPath, 'symbols')
const electronDownloadPath = path.join(repositoryRootPath, 'electron')
const homeDirPath = process.env.HOME || process.env.USERPROFILE
const atomHomeDirPath = process.env.ATOM_HOME || path.join(homeDirPath, '.atom')
2016-08-02 15:04:45 +03:00
const appMetadata = require(path.join(repositoryRootPath, 'package.json'))
const apmMetadata = require(path.join(apmRootPath, 'package.json'))
const channel = getChannel()
module.exports = {
2017-01-25 19:13:42 +03:00
appMetadata,
apmMetadata,
channel,
repositoryRootPath,
apmRootPath,
scriptRootPath,
buildOutputPath,
docsOutputPath,
intermediateAppPath,
symbolsPath,
electronDownloadPath,
atomHomeDirPath,
homeDirPath,
getApmBinPath,
getNpmBinPath,
snapshotAuxiliaryData: {}
}
2016-07-28 19:52:23 +03:00
function getChannel () {
if (appMetadata.version.match(/dev/)) {
2016-07-28 19:52:23 +03:00
return 'dev'
} else if (appMetadata.version.match(/beta/)) {
return 'beta'
} else {
return 'stable'
}
}
2016-08-02 15:04:45 +03:00
function getApmBinPath () {
const apmBinName = process.platform === 'win32' ? 'apm.cmd' : 'apm'
2016-08-02 15:55:34 +03:00
return path.join(apmRootPath, 'node_modules', 'atom-package-manager', 'bin', apmBinName)
2016-08-02 15:04:45 +03:00
}
function getNpmBinPath () {
const npmBinName = process.platform === 'win32' ? 'npm.cmd' : 'npm'
const localNpmBinPath = path.resolve(repositoryRootPath, 'script', 'node_modules', '.bin', npmBinName)
return fs.existsSync(localNpmBinPath) ? localNpmBinPath : npmBinName
}