22
33'use strict'
44
5+ const CONFIG = require ( './config' )
6+
57if ( process . argv . includes ( '--no-bootstrap' ) ) {
68 console . log ( 'Skipping bootstrap' )
79} else {
810 // Bootstrap first to ensure all the dependencies used later in this script
911 // are installed.
10- require ( './bootstrap' )
12+ const path = require ( 'path' )
13+ const childProcess = require ( 'child_process' )
14+ childProcess . execFileSync ( process . execPath , [ path . join ( CONFIG . scriptRootPath , 'bootstrap' ) ] , { env : process . env , cwd : CONFIG . repositoryRootPath , stdio : 'inherit' } ) ;
1115}
1216
1317// Required to load CS files in this build script, such as those in `donna`
@@ -52,47 +56,49 @@ const notarizeOnMac = require('./lib/notarize-on-mac')
5256const packageApplication = require ( './lib/package-application' )
5357const prebuildLessCache = require ( './lib/prebuild-less-cache' )
5458const testSignOnMac = require ( './lib/test-sign-on-mac' )
55- const transpileBabelPaths = require ( './lib/transpile-babel-paths' )
56- const transpileCoffeeScriptPaths = require ( './lib/transpile-coffee-script-paths' )
57- const transpileCsonPaths = require ( './lib/transpile-cson-paths' )
58- const transpilePegJsPaths = require ( './lib/transpile-peg-js-paths' )
59- const transpilePackagesWithCustomTranspilerPaths = require ( './lib/transpile-packages-with-custom-transpiler-paths.js' )
6059
6160process . on ( 'unhandledRejection' , function ( e ) {
6261 console . error ( e . stack || e )
6362 process . exit ( 1 )
6463} )
6564
66- const CONFIG = require ( './config' )
67-
68- // Used by the 'github' package for Babel configuration
6965process . env . ELECTRON_VERSION = CONFIG . appMetadata . electronVersion
7066
71- let binariesPromise = Promise . resolve ( )
72-
73- if ( ! argv . existingBinaries ) {
74- checkChromedriverVersion ( )
75- cleanOutputDirectory ( )
76- copyAssets ( )
77- transpilePackagesWithCustomTranspilerPaths ( )
78- transpileBabelPaths ( )
79- transpileCoffeeScriptPaths ( )
80- transpileCsonPaths ( )
81- transpilePegJsPaths ( )
82- generateModuleCache ( )
83- prebuildLessCache ( )
84- generateMetadata ( )
85- generateAPIDocs ( )
86- if ( ! argv . generateApiDocs ) {
87- binariesPromise = dumpSymbols ( )
88- }
67+ async function transpile ( ) {
68+ const { spawn, Thread, Worker } = require ( `${ CONFIG . scriptRunnerModulesPath } /threads` )
69+
70+ const transpilePackagesWithCustomTranspilerPaths = await spawn ( new Worker ( './lib/transpile-packages-with-custom-transpiler-paths' ) )
71+ const transpilePackagesWithCustomTranspilerPathsPromise = transpilePackagesWithCustomTranspilerPaths ( )
72+
73+ const transpileBabelPaths = await spawn ( new Worker ( './lib/transpile-babel-paths' ) )
74+ const transpileBabelPathsPromise = transpileBabelPaths ( )
75+
76+ const transpileCoffeeScriptPaths = await spawn ( new Worker ( './lib/transpile-coffee-script-paths' ) )
77+ const transpileCoffeeScriptPathsPromise = transpileCoffeeScriptPaths ( )
78+
79+ const transpileCsonPaths = await spawn ( new Worker ( './lib/transpile-cson-paths' ) )
80+ const transpileCsonPathsPromise = transpileCsonPaths ( )
81+
82+ const transpilePegJsPaths = await spawn ( new Worker ( './lib/transpile-peg-js-paths' ) )
83+ const transpilePegJsPathsPromise = transpilePegJsPaths ( )
84+
85+ await transpilePackagesWithCustomTranspilerPathsPromise ;
86+ await Thread . terminate ( transpilePackagesWithCustomTranspilerPaths )
87+
88+ await transpileBabelPathsPromise ;
89+ await Thread . terminate ( transpileBabelPaths )
90+
91+ await transpileCoffeeScriptPathsPromise ;
92+ await Thread . terminate ( transpileCoffeeScriptPaths )
93+
94+ await transpileCsonPathsPromise ;
95+ await Thread . terminate ( transpileCsonPaths )
96+
97+ await transpilePegJsPathsPromise ;
98+ await Thread . terminate ( transpilePegJsPaths )
8999}
90100
91- if ( ! argv . generateApiDocs ) {
92- binariesPromise
93- . then ( packageApplication )
94- . then ( packagedAppPath => generateStartupSnapshot ( packagedAppPath ) . then ( ( ) => packagedAppPath ) )
95- . then ( async packagedAppPath => {
101+ async function singAndCreateInstaller ( packagedAppPath ) {
96102 switch ( process . platform ) {
97103 case 'darwin' : {
98104 if ( argv . codeSign ) {
@@ -147,7 +153,29 @@ if (!argv.generateApiDocs) {
147153 }
148154
149155 return Promise . resolve ( packagedAppPath )
150- } ) . then ( packagedAppPath => {
156+ }
157+
158+
159+ async function build ( ) {
160+
161+ if ( ! argv . existingBinaries ) {
162+ checkChromedriverVersion ( )
163+ await cleanOutputDirectory ( )
164+ await copyAssets ( )
165+ await transpile ( )
166+ generateModuleCache ( )
167+ prebuildLessCache ( )
168+ generateMetadata ( )
169+ generateAPIDocs ( )
170+ if ( ! argv . generateApiDocs ) {
171+ await dumpSymbols ( )
172+ }
173+ }
174+
175+ if ( ! argv . generateApiDocs ) {
176+ const packagedAppPath = await packageApplication ( )
177+ await generateStartupSnapshot ( packagedAppPath )
178+ await singAndCreateInstaller ( packagedAppPath )
151179 if ( argv . compressArtifacts ) {
152180 compressArtifacts ( packagedAppPath )
153181 } else {
@@ -159,5 +187,9 @@ if (!argv.generateApiDocs) {
159187 } else {
160188 console . log ( 'Skipping installation. Specify the --install option to install Atom' . gray )
161189 }
162- } )
190+ }
191+
163192}
193+
194+
195+ build ( ) . then ( ( ) => { process . exit ( 0 ) } ) . catch ( ( e ) => { throw e ; } )
0 commit comments