Skip to content

Commit d2d3ed3

Browse files
committed
fix: release script
1 parent e900d5d commit d2d3ed3

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

packages/deploy/release-script/utils.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import { exec } from 'child_process'
22

3-
const fs = require('fs')
4-
const semver = require('semver')
5-
const path = require('path')
3+
import fs from 'fs'
4+
import semver from 'semver'
5+
import path from 'path'
6+
import { fileURLToPath } from 'url'
7+
8+
const __filename = fileURLToPath(import.meta.url)
9+
const __dirname = path.dirname(__filename)
610

711
export const bumpGithubTemplateVersions = (newVersion: string): string => {
812
// Bump patch .version in package.json.
@@ -37,7 +41,7 @@ export const bumpVersionInGenerators = (newVersion: string): string => {
3741
export const bumpPackageJsonVersion = (filePath: string, newVersion: string): string => {
3842
// Bump patch .version in package.json.
3943
const packageJsonPath = path.resolve(__dirname, filePath)
40-
const packageJson: { version: string } = JSON.parse(fs.readFileSync(packageJsonPath))
44+
const packageJson: { version: string } = JSON.parse(fs.readFileSync(packageJsonPath).toString())
4145
packageJson.version = newVersion
4246
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
4347
console.log('vuestic-ui package.json version has been updated')
@@ -52,12 +56,10 @@ export const getRecommendedNodeVersion = (): string => {
5256
export const getPackageJsonVersion = (): string => {
5357
const packageJsonPath = path.resolve(__dirname, '../../../packages/ui/package.json')
5458
// Coerce keeps only 1.2.3 from full version string - useful in case we sit on some weird version.
55-
return semver.coerce(JSON.parse(fs.readFileSync(packageJsonPath)).version)
59+
return semver.coerce(JSON.parse(fs.readFileSync(packageJsonPath).toString()).version)!.toString()
5660
}
5761

5862
export const executeCommand = (command: string): Promise<string> => {
59-
const { exec } = require('child_process')
60-
6163
let _resolve: any
6264
let _reject: any
6365
exec(command, (err: any, stdout: any, stderr: any) => {

0 commit comments

Comments
 (0)