Skip to content

Commit 2f337e8

Browse files
authored
Target Folder (JamesIves#268)
* Creating target folder * Formatting
1 parent 88b3e19 commit 2f337e8

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

__tests__/git.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
process.env['INPUT_FOLDER'] = 'build'
33
process.env['GITHUB_SHA'] = '123'
44

5+
import {mkdirP, rmRF} from '@actions/io'
56
import {action} from '../src/constants'
6-
import {deploy, generateBranch, init, switchToBaseBranch} from '../src/git'
77
import {execute} from '../src/execute'
8-
import {rmRF} from '@actions/io'
8+
import {deploy, generateBranch, init, switchToBaseBranch} from '../src/git'
99

1010
const originalAction = JSON.stringify(action)
1111

@@ -17,7 +17,8 @@ jest.mock('@actions/core', () => ({
1717
}))
1818

1919
jest.mock('@actions/io', () => ({
20-
rmRF: jest.fn()
20+
rmRF: jest.fn(),
21+
mkdirP: jest.fn()
2122
}))
2223

2324
jest.mock('../src/execute', () => ({
@@ -402,6 +403,7 @@ describe('git', () => {
402403

403404
expect(execute).toBeCalledTimes(11)
404405
expect(rmRF).toBeCalledTimes(1)
406+
expect(mkdirP).toBeCalledTimes(1)
405407
})
406408

407409
it('should stop early if there is nothing to commit', async () => {

src/git.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {info} from '@actions/core'
2-
import {rmRF} from '@actions/io'
2+
import {rmRF, mkdirP} from '@actions/io'
33
import {ActionInterface} from './constants'
44
import {execute} from './execute'
55
import {
@@ -147,6 +147,11 @@ export async function deploy(action: ActionInterface): Promise<void> {
147147
}
148148
}
149149

150+
if (action.targetFolder) {
151+
info(`Creating target folder if it doesn't already exist… 📌`)
152+
await mkdirP(`${temporaryDeploymentDirectory}/${action.targetFolder}`)
153+
}
154+
150155
/*
151156
Pushes all of the build files into the deployment directory.
152157
Allows the user to specify the root if '.' is provided.

0 commit comments

Comments
 (0)