Skip to content

Commit 9a4a1a1

Browse files
committed
Fix tests and async call in changelog write
1 parent b2a3811 commit 9a4a1a1

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

__tests__/changelog.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@ import {Changelog} from '../src/changelog'
66
import {GitCommit} from '../src/git'
77
import {TEST_DIR} from './common.test.utils'
88

9+
const CHANGELOG_TEST_DIR = path.join(TEST_DIR, 'changelog')
10+
911
describe('Changelog', () => {
1012
afterAll(() => {
11-
io.rmRF(TEST_DIR)
13+
io.rmRF(CHANGELOG_TEST_DIR)
1214
})
1315

1416
it('Verifies changelog is saved to file', async () => {
1517
const settings = {} as Settings
16-
settings.changelogFilePath = path.join(TEST_DIR, 'CHANGELOG.md')
18+
settings.changelogFilePath = path.join(CHANGELOG_TEST_DIR, 'CHANGELOG.md')
1719

1820
// Verifies path doesn't exists
19-
expect(fs.existsSync(TEST_DIR)).toBe(false)
21+
expect(fs.existsSync(CHANGELOG_TEST_DIR)).toBe(false)
2022

2123
const gitLog: GitCommit[] = [
2224
new GitCommit('295b513', 'Third commit'),

__tests__/git.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ import {Git} from '../src/git'
77
import {Settings} from '../src/settings'
88
import {TEST_DIR} from './common.test.utils'
99

10+
const GIT_TEST_DIR = path.join(TEST_DIR, 'git')
11+
1012
async function runGit(args: string[], cwd: string) {
1113
const gitPath = await io.which('git', true)
1214
await exec.exec(`"${gitPath}"`, args, {cwd})
1315
}
1416

1517
async function initTestRepo(): Promise<string> {
16-
const cwd = path.join(TEST_DIR, uuid.v4())
18+
const cwd = path.join(GIT_TEST_DIR, uuid.v4())
1719
await io.mkdirP(cwd)
1820
await runGit(['init', '.'], cwd)
1921
return cwd
@@ -32,7 +34,7 @@ async function createAndCommitFile(name: string, message: string, cwd: string) {
3234

3335
describe('Git commands', () => {
3436
afterAll(() => {
35-
io.rmRF(TEST_DIR)
37+
io.rmRF(GIT_TEST_DIR)
3638
})
3739

3840
it('Verifies tag is returned if checked out on same commit', async () => {

src/changelog.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as fs from 'fs'
22
import * as path from 'path'
3-
import * as io from '@actions/io'
43
import {Settings} from './settings'
54
import {GitCommit} from './git'
65

@@ -20,7 +19,7 @@ export class Changelog {
2019

2120
const changelogDir: string = path.parse(this.settings.changelogFilePath).dir
2221
if (!fs.existsSync(changelogDir)) {
23-
io.mkdirP(changelogDir)
22+
fs.mkdirSync(changelogDir)
2423
}
2524

2625
fs.writeFileSync(this.settings.changelogFilePath, lines.join('\n'))

0 commit comments

Comments
 (0)