From 3a1403f33ea8183771ec7c2497e6f27d8fdc9409 Mon Sep 17 00:00:00 2001 From: peaceiris <30958501+peaceiris@users.noreply.github.com> Date: Sun, 2 Aug 2020 15:01:49 +0900 Subject: [PATCH 1/2] feat: Add .nojekyll file by default for all branches --- __tests__/utils.test.ts | 60 ++++------------------------------------- src/utils.ts | 18 +++++-------- 2 files changed, 11 insertions(+), 67 deletions(-) diff --git a/__tests__/utils.test.ts b/__tests__/utils.test.ts index d893b122b..31eaefc0a 100644 --- a/__tests__/utils.test.ts +++ b/__tests__/utils.test.ts @@ -70,28 +70,14 @@ async function getWorkDir(): Promise { } describe('addNoJekyll()', () => { - test('add .nojekyll gh-pages', async () => { + test('add .nojekyll', async () => { let workDir = ''; (async (): Promise => { workDir = await getWorkDir(); })(); const filepath = path.join(workDir, '.nojekyll'); - await addNoJekyll(workDir, false, 'gh-pages'); - const test = fs.existsSync(filepath); - expect(test).toBe(true); - - fs.unlinkSync(filepath); - }); - - test('add .nojekyll master', async () => { - let workDir = ''; - (async (): Promise => { - workDir = await getWorkDir(); - })(); - const filepath = path.join(workDir, '.nojekyll'); - - await addNoJekyll(workDir, false, 'master'); + await addNoJekyll(workDir, false); const test = fs.existsSync(filepath); expect(test).toBe(true); @@ -106,57 +92,21 @@ describe('addNoJekyll()', () => { const filepath = path.join(workDir, '.nojekyll'); fs.closeSync(fs.openSync(filepath, 'w')); - await addNoJekyll(workDir, false, 'master'); + await addNoJekyll(workDir, false); const test = fs.existsSync(filepath); expect(test).toBe(true); fs.unlinkSync(filepath); }); - test('not add .nojekyll disable_nojekyll gh-pages', async () => { - let workDir = ''; - (async (): Promise => { - workDir = await getWorkDir(); - })(); - const filepath = path.join(workDir, '.nojekyll'); - - await addNoJekyll(workDir, true, 'gh-pages'); - const test = fs.existsSync(filepath); - expect(test).toBe(false); - }); - - test('not add .nojekyll disable_nojekyll master', async () => { - let workDir = ''; - (async (): Promise => { - workDir = await getWorkDir(); - })(); - const filepath = path.join(workDir, '.nojekyll'); - - await addNoJekyll(workDir, true, 'master'); - const test = fs.existsSync(filepath); - expect(test).toBe(false); - }); - - test('not add .nojekyll other-branch', async () => { - let workDir = ''; - (async (): Promise => { - workDir = await getWorkDir(); - })(); - const filepath = path.join(workDir, '.nojekyll'); - - await addNoJekyll(workDir, false, 'other-branch'); - const test = fs.existsSync(filepath); - expect(test).toBe(false); - }); - - test('not add .nojekyll disable_nojekyll other-branch', async () => { + test('not add .nojekyll disable_nojekyll', async () => { let workDir = ''; (async (): Promise => { workDir = await getWorkDir(); })(); const filepath = path.join(workDir, '.nojekyll'); - await addNoJekyll(workDir, true, 'other-branch'); + await addNoJekyll(workDir, true); const test = fs.existsSync(filepath); expect(test).toBe(false); }); diff --git a/src/utils.ts b/src/utils.ts index a18e1ecfe..eaf457e51 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -29,22 +29,16 @@ export async function createDir(dirPath: string): Promise { return; } -export async function addNoJekyll( - workDir: string, - DisableNoJekyll: boolean, - PublishBranch: string -): Promise { +export async function addNoJekyll(workDir: string, DisableNoJekyll: boolean): Promise { if (DisableNoJekyll) { return; } - if (PublishBranch === 'master' || PublishBranch === 'gh-pages') { - const filepath = path.join(workDir, '.nojekyll'); - if (fs.existsSync(filepath)) { - return; - } - fs.closeSync(fs.openSync(filepath, 'w')); - core.info(`[INFO] Created ${filepath}`); + const filepath = path.join(workDir, '.nojekyll'); + if (fs.existsSync(filepath)) { + return; } + fs.closeSync(fs.openSync(filepath, 'w')); + core.info(`[INFO] Created ${filepath}`); } export async function addCNAME(workDir: string, content: string): Promise { From eca2593db32f7a3fbc950ed73b2d48137de85def Mon Sep 17 00:00:00 2001 From: peaceiris <30958501+peaceiris@users.noreply.github.com> Date: Sun, 2 Aug 2020 15:05:30 +0900 Subject: [PATCH 2/2] fix --- src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 2688531b7..14d8cfe4c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -48,7 +48,7 @@ export async function run(): Promise { const unixTime = date.getTime(); const workDir = await getWorkDirName(`${unixTime}`); await setRepo(inps, remoteURL, workDir); - await addNoJekyll(workDir, inps.DisableNoJekyll, inps.PublishBranch); + await addNoJekyll(workDir, inps.DisableNoJekyll); await addCNAME(workDir, inps.CNAME); core.endGroup();