Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dev-env/basic): building and running development #1646

Merged
merged 2 commits into from Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/docz-rollup/package.json
Expand Up @@ -28,7 +28,7 @@
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-peer-deps-external": "^2.2.0",
"rollup-plugin-postcss": "^2.0.3",
"rollup-plugin-progress": "^1.1.1",
"rollup-plugin-progress": "^1.1.2",
"rollup-plugin-typescript2": "^0.22.0"
},
"devDependencies": {
Expand Down
22 changes: 13 additions & 9 deletions dev-env/basic/dev.js
Expand Up @@ -45,6 +45,7 @@ const watchPackage = async (name, outputDir) => {
const destinationPath = getDestinationPath(name, outputDir)
const sourceRootPath = path.join(rootPath, `core/${name}/`)
const dev = runCommand(`yarn run dev`, { cwd: sourceRootPath })

try {
await runCommand(`yarn run build`, { cwd: sourceRootPath })
} catch (err) {
Expand All @@ -65,8 +66,7 @@ const watchPackage = async (name, outputDir) => {
cpx.watch(`${sourcePath}/lib/**/*`, getDestinationPath(name, 'lib'))
)
} else {
const sync = cpx.watch(`${sourcePath}/**/*`, destinationPath)
fileWatchers.push(sync)
fileWatchers.push(cpx.watch(`${sourcePath}/**/*`, destinationPath))
}

const unsubscribers = fileWatchers.map(fileWatcher => {
Expand All @@ -81,12 +81,15 @@ const watchPackage = async (name, outputDir) => {
}
return stop
})

const stop = () => {
dev.cancel()
unsubscribers.forEach(unsub => {
unsub()
})
}

console.log('watching package: ', name)
return stop
}

Expand All @@ -97,20 +100,21 @@ const main = async () => {
for (let stopWatching of watchStoppers) {
stopWatching()
}

console.log(`\nTerminated ${watchStoppers.length} running processes\n`)
process.exit(0)
})

const build = runCommand(`yarn packages:build`, { cwd: rootPath })

watchStoppers.push(() => build.cancel())

await build
for (let package of packages) {
const stopWatchingPackage = await watchPackage(
package.name,
package.outputDir
)
console.log('watching package ', package.name)
watchStoppers.push(stopWatchingPackage)

for (const package of packages) {
watchStoppers.push(await watchPackage(package.name, package.outputDir))
}

const dev = runCommand(`yarn docz dev`, { cwd: __dirname })
watchStoppers.push(() => dev.cancel())
}
Expand Down
2 changes: 1 addition & 1 deletion dev-env/basic/package.json
Expand Up @@ -15,7 +15,7 @@
},
"dependencies": {
"cpx": "^1.5.0",
"docz": "next",
"docz": "../../core/docz",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

"execa": "^2.0.4",
"prop-types": "^15.7.2",
"react": "^16.8.6",
Expand Down