-
-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: build version file for moonraker (#1449)
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import fs from 'fs' | ||
import path from 'path' | ||
import { version } from '../../package.json' | ||
import { PluginOption } from 'vite' | ||
|
||
/** | ||
* Custom build plugin to write the version in a dedicated release_info.json file after bundling | ||
*/ | ||
|
||
export default function buildReleaseInfo(): PluginOption { | ||
return { | ||
name: 'build-release_info', | ||
writeBundle: () => { | ||
setImmediate(async () => { | ||
const versionIdentifier = version.toString() | ||
const releaseInfoFile = await fs.promises.open( | ||
path.resolve(__dirname, '../../dist/release_info.json'), | ||
'w' | ||
) | ||
await releaseInfoFile.writeFile( | ||
JSON.stringify({ | ||
project_name: 'mainsail', | ||
project_owner: 'mainsail-crew', | ||
version: `v${versionIdentifier}`, | ||
}) | ||
) | ||
await releaseInfoFile.close() | ||
}) | ||
}, | ||
} | ||
} |
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