88//
99
1010import * as child_process from 'child_process'
11- import * as fs from 'fs-extra '
11+ import * as nodefs from 'fs'
1212import * as path from 'path'
1313
1414// Must run from a subproject root folder, e.g packages/toolkit
1515const cwd = process . cwd ( )
16- const packageJson = JSON . parse ( fs . readFileSync ( './package.json' , { encoding : 'utf-8' } ) )
16+ const packageJson = JSON . parse ( nodefs . readFileSync ( './package.json' , { encoding : 'utf-8' } ) )
1717const changesDirectory = path . join ( cwd , '.changes' )
1818const nextReleaseDirectory = path . join ( changesDirectory , 'next-release' )
1919const changesFile = path . join ( changesDirectory , `${ packageJson . version } .json` )
2020
21- fs . mkdirpSync ( nextReleaseDirectory )
21+ nodefs . mkdirSync ( nextReleaseDirectory , { recursive : true } )
2222
23- const changeFiles = fs . readdirSync ( nextReleaseDirectory )
23+ const changeFiles = nodefs . readdirSync ( nextReleaseDirectory )
2424if ( changeFiles . length === 0 ) {
2525 console . warn ( 'no changes to release (missing .changes/ directory)' )
2626 process . exit ( )
2727}
2828try {
29- fs . accessSync ( changesFile )
29+ nodefs . accessSync ( changesFile )
3030 console . log ( `error: changelog data file already exists: ${ changesFile } ` )
3131 process . exit ( - 1 )
3232} catch ( err ) {
@@ -41,22 +41,22 @@ const changelog: any = {
4141}
4242
4343for ( const changeFile of changeFiles ) {
44- const file = JSON . parse ( fs . readFileSync ( path . join ( nextReleaseDirectory , changeFile ) ) . toString ( ) )
44+ const file = JSON . parse ( nodefs . readFileSync ( path . join ( nextReleaseDirectory , changeFile ) ) . toString ( ) )
4545 changelog . entries . push ( file )
4646}
4747
4848changelog . entries . sort ( ( x : { type : string } , y : { type : string } ) => x . type . localeCompare ( y . type ) )
4949
5050// Write changelog file
51- fs . writeFileSync ( changesFile , JSON . stringify ( changelog , undefined , '\t' ) )
52- const fileData = fs . readFileSync ( path . join ( cwd , 'CHANGELOG.md' ) )
51+ nodefs . writeFileSync ( changesFile , JSON . stringify ( changelog , undefined , '\t' ) )
52+ const fileData = nodefs . readFileSync ( path . join ( cwd , 'CHANGELOG.md' ) )
5353let append = `## ${ packageJson . version } ${ timestamp } \n\n`
5454for ( const file of changelog . entries ) {
5555 append += `- **${ file . type } ** ${ file . description } \n`
5656}
5757
5858append += '\n' + fileData . toString ( )
59- fs . writeFileSync ( 'CHANGELOG.md' , append )
59+ nodefs . writeFileSync ( 'CHANGELOG.md' , append )
6060
6161child_process . execSync ( `git add ${ changesDirectory } ` )
6262child_process . execSync ( `git rm -rf ${ nextReleaseDirectory } ` )
0 commit comments