pulsar/script/build
2016-08-13 12:01:23 +02:00

85 lines
3.1 KiB
JavaScript
Executable File

#!/usr/bin/env node
'use strict'
// Needed so we can require src/module-cache.coffee during generateModuleCache
require('coffee-script/register')
require('colors')
const argv = require('yargs')
.usage('Usage: $0 [options]')
.help('help')
.describe('code-sign', 'Code-sign executables (key specified in env vars)')
.describe('create-installer', 'Create installer (Windows only)')
.describe('compress-artifacts', 'Compress Atom binaries (and symbols on macOS)')
.describe('install', 'Install Atom')
.argv
const cleanOutputDirectory = require('./lib/clean-output-directory')
const codeSignOnMac = require('./lib/code-sign-on-mac')
const compressArtifacts = require('./lib/compress-artifacts')
const copyAssets = require('./lib/copy-assets')
const createWindowsInstaller = require('./lib/create-windows-installer')
const downloadChromedriver = require('./lib/download-chromedriver')
const dumpSymbols = require('./lib/dump-symbols')
const generateAPIDocs = require('./lib/generate-api-docs')
const generateMetadata = require('./lib/generate-metadata')
const generateModuleCache = require('./lib/generate-module-cache')
const installApplication = require('./lib/install-application')
const packageApplication = require('./lib/package-application')
const prebuildLessCache = require('./lib/prebuild-less-cache')
const transpileBabelPaths = require('./lib/transpile-babel-paths')
const transpileCoffeeScriptPaths = require('./lib/transpile-coffee-script-paths')
const transpileCsonPaths = require('./lib/transpile-cson-paths')
const transpilePegJsPaths = require('./lib/transpile-peg-js-paths')
process.on('unhandledRejection', function (e) {
console.error(e)
process.exit(1)
})
cleanOutputDirectory()
copyAssets()
transpileBabelPaths()
transpileCoffeeScriptPaths()
transpileCsonPaths()
transpilePegJsPaths()
generateModuleCache()
prebuildLessCache()
generateMetadata()
generateAPIDocs()
downloadChromedriver()
dumpSymbols()
.then(packageApplication)
.then(packagedAppPath => {
if (process.platform === 'darwin') {
if (argv.codeSign) {
codeSignOnMac(packagedAppPath)
} else {
console.log('Skipping code-signing. Specify the --code-sign option to perform code-signing'.gray)
}
return Promise.resolve(packagedAppPath)
} else if (process.platform === 'win32') {
if (argv.createInstaller) {
return createWindowsInstaller(packagedAppPath, argv.codeSign).then(() => packagedAppPath)
}
else {
console.log('Skipping creating installer. Specify the --create-installer option to create a Squirrel-based Windows installer.'.gray)
}
} else {
return Promise.resolve(packagedAppPath)
}
}).then(packagedAppPath => {
if (argv.compressArtifacts) {
compressArtifacts(packagedAppPath)
} else {
console.log('Skipping artifacts compression. Specify the --compress-artifacts option to compress Atom binaries (and symbols on macOS)'.gray)
}
if (argv.install) {
installApplication(packagedAppPath)
} else {
console.log('Skipping installation. Specify the --install option to install Atom'.gray)
}
})