-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(backend): バックエンドのpnpm devによるビルド後にbuild-assetsを行うようにする (#13659)
* moveto scripts * add scripts/dev.mjs
- Loading branch information
1 parent
c4fc582
commit efa42a1
Showing
6 changed files
with
71 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* SPDX-FileCopyrightText: syuilo and misskey-project | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
import { execa, execaNode } from 'execa'; | ||
|
||
/** @type {import('execa').ExecaChildProcess | undefined} */ | ||
let backendProcess; | ||
|
||
async function execBuildAssets() { | ||
await execa('pnpm', ['run', 'build-assets'], { | ||
cwd: '../../', | ||
stdout: process.stdout, | ||
stderr: process.stderr, | ||
}) | ||
} | ||
|
||
function execStart() { | ||
// pnpm run start を呼び出したいが、windowsだとプロセスグループ単位でのkillが出来ずゾンビプロセス化するので | ||
// 上記と同等の動きをするコマンドで子・孫プロセスを作らないようにしたい | ||
backendProcess = execaNode('./built/boot/entry.js', [], { | ||
stdout: process.stdout, | ||
stderr: process.stderr, | ||
env: { | ||
'NODE_ENV': 'development', | ||
}, | ||
}); | ||
} | ||
|
||
async function killProc() { | ||
if (backendProcess) { | ||
backendProcess.kill(); | ||
await new Promise(resolve => backendProcess.on('exit', resolve)); | ||
backendProcess = undefined; | ||
} | ||
} | ||
|
||
(async () => { | ||
execaNode( | ||
'./node_modules/nodemon/bin/nodemon.js', | ||
[ | ||
'-w', 'src', | ||
'-e', 'ts,js,mjs,cjs,json', | ||
'--exec', 'pnpm', 'run', 'build', | ||
], | ||
{ | ||
stdio: [process.stdin, process.stdout, process.stderr, 'ipc'], | ||
}) | ||
.on('message', async (message) => { | ||
if (message.type === 'exit') { | ||
// かならずbuild->build-assetsの順番で呼び出したいので、 | ||
// 少々トリッキーだがnodemonからのexitイベントを利用してbuild-assets->startを行う。 | ||
// pnpm restartをbuildが終わる前にbuild-assetsが動いてしまうので、バラバラに呼び出す必要がある | ||
|
||
await killProc(); | ||
await execBuildAssets(); | ||
execStart(); | ||
} | ||
}) | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
efa42a1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chromatic detects changes. Please review the changes on Chromatic.