1
1
import { exec } from 'child_process'
2
2
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 )
6
10
7
11
export const bumpGithubTemplateVersions = ( newVersion : string ) : string => {
8
12
// Bump patch .version in package.json.
@@ -37,7 +41,7 @@ export const bumpVersionInGenerators = (newVersion: string): string => {
37
41
export const bumpPackageJsonVersion = ( filePath : string , newVersion : string ) : string => {
38
42
// Bump patch .version in package.json.
39
43
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 ( ) )
41
45
packageJson . version = newVersion
42
46
fs . writeFileSync ( packageJsonPath , JSON . stringify ( packageJson , null , 2 ) )
43
47
console . log ( 'vuestic-ui package.json version has been updated' )
@@ -52,12 +56,10 @@ export const getRecommendedNodeVersion = (): string => {
52
56
export const getPackageJsonVersion = ( ) : string => {
53
57
const packageJsonPath = path . resolve ( __dirname , '../../../packages/ui/package.json' )
54
58
// 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 ( )
56
60
}
57
61
58
62
export const executeCommand = ( command : string ) : Promise < string > => {
59
- const { exec } = require ( 'child_process' )
60
-
61
63
let _resolve : any
62
64
let _reject : any
63
65
exec ( command , ( err : any , stdout : any , stderr : any ) => {
0 commit comments