Skip to content

Commit b8f876d

Browse files
committed
update create release
1 parent ee1682d commit b8f876d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

scripts/createRelease.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@
88
//
99

1010
import * as child_process from 'child_process'
11-
import * as fs from 'fs-extra'
11+
import * as nodefs from 'fs'
1212
import * as path from 'path'
1313

1414
// Must run from a subproject root folder, e.g packages/toolkit
1515
const 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' }))
1717
const changesDirectory = path.join(cwd, '.changes')
1818
const nextReleaseDirectory = path.join(changesDirectory, 'next-release')
1919
const 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)
2424
if (changeFiles.length === 0) {
2525
console.warn('no changes to release (missing .changes/ directory)')
2626
process.exit()
2727
}
2828
try {
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

4343
for (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

4848
changelog.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'))
5353
let append = `## ${packageJson.version} ${timestamp}\n\n`
5454
for (const file of changelog.entries) {
5555
append += `- **${file.type}** ${file.description}\n`
5656
}
5757

5858
append += '\n' + fileData.toString()
59-
fs.writeFileSync('CHANGELOG.md', append)
59+
nodefs.writeFileSync('CHANGELOG.md', append)
6060

6161
child_process.execSync(`git add ${changesDirectory}`)
6262
child_process.execSync(`git rm -rf ${nextReleaseDirectory}`)

0 commit comments

Comments
 (0)