| 1 | #!/usr/bin/env node |
| 2 | |
| 3 | 'use strict'; |
| 4 | |
| 5 | const {exec} = require('child-process-promise'); |
| 6 | const {join} = require('path'); |
| 7 | const {logPromise} = require('../utils'); |
| 8 | const shell = require('shelljs'); |
| 9 | |
| 10 | const run = async ({cwd, dry, tempDirectory}) => { |
| 11 | const defaultOptions = { |
| 12 | cwd: tempDirectory, |
| 13 | }; |
| 14 | |
| 15 | await exec('yarn install', defaultOptions); |
| 16 | await exec('yarn build -- --extract-errors', defaultOptions); |
| 17 | |
| 18 | const tempNodeModulesPath = join(tempDirectory, 'build', 'node_modules'); |
| 19 | const buildPath = join(cwd, 'build'); |
| 20 | |
| 21 | shell.cp('-r', tempNodeModulesPath, buildPath); |
| 22 | }; |
| 23 | |
| 24 | module.exports = async params => { |
| 25 | return logPromise(run(params), 'Building artifacts', 600000); |
| 26 | }; |