fix: version check

This commit is contained in:
himself65 2023-05-17 17:36:59 -07:00
parent d6b640726e
commit fbe2543c03
No known key found for this signature in database
GPG Key ID: 35F07049B7A1E625

View File

@ -1,8 +1,11 @@
#!/usr/bin/env zx
import 'zx/globals';
import { createRequire } from 'node:module';
import path from 'node:path';
const require = createRequire(import.meta.url);
const repoRootDir = path.join(__dirname, '..', '..', '..');
const electronRootDir = path.join(__dirname, '..');
const publicDistDir = path.join(electronRootDir, 'resources');
@ -21,11 +24,7 @@ console.log('build with following dir', {
});
// step 0: check version match
const electronPackageJson = await import(`${electronRootDir}/package.json`, {
assert: {
type: 'json',
},
});
const electronPackageJson = require(`${electronRootDir}/package.json`);
if (releaseVersionEnv && electronPackageJson.version !== releaseVersionEnv) {
throw new Error(
`Version mismatch, expected ${releaseVersionEnv} but got ${electronPackageJson.version}`