Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Commit

Permalink
Made exporting renderer work on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
leo committed Feb 8, 2018
1 parent 26b0686 commit 57dc52f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 35 deletions.
28 changes: 4 additions & 24 deletions lib/build/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,44 @@ const { join } = require('path')
const { exec: defaultExec } = require('child_process')
const { promisify } = require('util')

// Packages
const resolveBin = require('resolve-binary')

// Utilities
const spinner = require('../spinner')

module.exports = async () => {
spinner.create('Building renderer code')

const cwd = process.cwd()
let binaryPath

try {
binaryPath = await resolveBin('next', {
paths: [
join(cwd, 'node_modules')
]
})
} catch (err) {
console.log(err)
if (err.code === 'MODULE_NOT_FOUND') {
spinner.fail(`Your project is missing the ${'`next`'} dependency`)
}

spinner.fail(`Not able to load the ${'`next`'} dependency`)
}

const renderer = join(cwd, 'renderer')
const exec = promisify(defaultExec)

let stderr

try {
({ stderr } = await exec(`${binaryPath} build ${renderer}`))
({ stderr } = await exec(`npx next build ${renderer}`, { cwd }))
} catch (err) {
spinner.fail('Not able to build renderer code')
return
}

// Just pass the error on from Next.js, don't
// apply any formatting at all
if (stderr) {
if (stderr && !stderr.includes('must be of type')) {
console.error(stderr)
process.exit(1)
}

spinner.create('Generating static bundle from renderer code')

try {
({ stderr } = await exec(`${binaryPath} export ${renderer}`))
({ stderr } = await exec(`npx next export ${renderer}`, { cwd }))
} catch (err) {
spinner.fail('Not able to export renderer code')
return
}

// Just pass the error on from Next.js, don't
// apply any formatting at all
if (stderr) {
if (stderr && !stderr.includes('must be of type')) {
console.error(stderr)
process.exit(1)
}
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"inquirer": "5.1.0",
"ora": "1.4.0",
"plist": "2.1.0",
"resolve-binary": "1.0.1",
"respawn": "2.5.0"
},
"peerDependencies": {
Expand Down
10 changes: 0 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -731,10 +731,6 @@ fill-range@^4.0.0:
repeat-string "^1.6.1"
to-regex-range "^2.1.0"

find-parent-dir@~0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/find-parent-dir/-/find-parent-dir-0.3.0.tgz#33c44b429ab2b2f0646299c5f9f718f376ff8d54"

fmix@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/fmix/-/fmix-0.1.0.tgz#c7bbf124dec42c9d191cfb947d0a9778dd986c0c"
Expand Down Expand Up @@ -1982,12 +1978,6 @@ require-object-coercible-x@^1.4.1:
dependencies:
is-nil-x "^1.4.1"

resolve-binary@1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/resolve-binary/-/resolve-binary-1.0.1.tgz#528fbf19cb1bc34c10e64747092b0abd8d0773b9"
dependencies:
find-parent-dir "~0.3.0"

resolve-url@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
Expand Down

0 comments on commit 57dc52f

Please sign in to comment.