Skip to content

Commit 079d483

Browse files
authored
feat: Add .nojekyll file by default for all branches (#438)
1 parent 4fb3d60 commit 079d483

File tree

3 files changed

+12
-68
lines changed

3 files changed

+12
-68
lines changed

__tests__/utils.test.ts

Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -70,28 +70,14 @@ async function getWorkDir(): Promise<string> {
7070
}
7171

7272
describe('addNoJekyll()', () => {
73-
test('add .nojekyll gh-pages', async () => {
73+
test('add .nojekyll', async () => {
7474
let workDir = '';
7575
(async (): Promise<void> => {
7676
workDir = await getWorkDir();
7777
})();
7878
const filepath = path.join(workDir, '.nojekyll');
7979

80-
await addNoJekyll(workDir, false, 'gh-pages');
81-
const test = fs.existsSync(filepath);
82-
expect(test).toBe(true);
83-
84-
fs.unlinkSync(filepath);
85-
});
86-
87-
test('add .nojekyll master', async () => {
88-
let workDir = '';
89-
(async (): Promise<void> => {
90-
workDir = await getWorkDir();
91-
})();
92-
const filepath = path.join(workDir, '.nojekyll');
93-
94-
await addNoJekyll(workDir, false, 'master');
80+
await addNoJekyll(workDir, false);
9581
const test = fs.existsSync(filepath);
9682
expect(test).toBe(true);
9783

@@ -106,57 +92,21 @@ describe('addNoJekyll()', () => {
10692
const filepath = path.join(workDir, '.nojekyll');
10793
fs.closeSync(fs.openSync(filepath, 'w'));
10894

109-
await addNoJekyll(workDir, false, 'master');
95+
await addNoJekyll(workDir, false);
11096
const test = fs.existsSync(filepath);
11197
expect(test).toBe(true);
11298

11399
fs.unlinkSync(filepath);
114100
});
115101

116-
test('not add .nojekyll disable_nojekyll gh-pages', async () => {
117-
let workDir = '';
118-
(async (): Promise<void> => {
119-
workDir = await getWorkDir();
120-
})();
121-
const filepath = path.join(workDir, '.nojekyll');
122-
123-
await addNoJekyll(workDir, true, 'gh-pages');
124-
const test = fs.existsSync(filepath);
125-
expect(test).toBe(false);
126-
});
127-
128-
test('not add .nojekyll disable_nojekyll master', async () => {
129-
let workDir = '';
130-
(async (): Promise<void> => {
131-
workDir = await getWorkDir();
132-
})();
133-
const filepath = path.join(workDir, '.nojekyll');
134-
135-
await addNoJekyll(workDir, true, 'master');
136-
const test = fs.existsSync(filepath);
137-
expect(test).toBe(false);
138-
});
139-
140-
test('not add .nojekyll other-branch', async () => {
141-
let workDir = '';
142-
(async (): Promise<void> => {
143-
workDir = await getWorkDir();
144-
})();
145-
const filepath = path.join(workDir, '.nojekyll');
146-
147-
await addNoJekyll(workDir, false, 'other-branch');
148-
const test = fs.existsSync(filepath);
149-
expect(test).toBe(false);
150-
});
151-
152-
test('not add .nojekyll disable_nojekyll other-branch', async () => {
102+
test('not add .nojekyll disable_nojekyll', async () => {
153103
let workDir = '';
154104
(async (): Promise<void> => {
155105
workDir = await getWorkDir();
156106
})();
157107
const filepath = path.join(workDir, '.nojekyll');
158108

159-
await addNoJekyll(workDir, true, 'other-branch');
109+
await addNoJekyll(workDir, true);
160110
const test = fs.existsSync(filepath);
161111
expect(test).toBe(false);
162112
});

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export async function run(): Promise<void> {
4848
const unixTime = date.getTime();
4949
const workDir = await getWorkDirName(`${unixTime}`);
5050
await setRepo(inps, remoteURL, workDir);
51-
await addNoJekyll(workDir, inps.DisableNoJekyll, inps.PublishBranch);
51+
await addNoJekyll(workDir, inps.DisableNoJekyll);
5252
await addCNAME(workDir, inps.CNAME);
5353
core.endGroup();
5454

src/utils.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,16 @@ export async function createDir(dirPath: string): Promise<void> {
2929
return;
3030
}
3131

32-
export async function addNoJekyll(
33-
workDir: string,
34-
DisableNoJekyll: boolean,
35-
PublishBranch: string
36-
): Promise<void> {
32+
export async function addNoJekyll(workDir: string, DisableNoJekyll: boolean): Promise<void> {
3733
if (DisableNoJekyll) {
3834
return;
3935
}
40-
if (PublishBranch === 'master' || PublishBranch === 'gh-pages') {
41-
const filepath = path.join(workDir, '.nojekyll');
42-
if (fs.existsSync(filepath)) {
43-
return;
44-
}
45-
fs.closeSync(fs.openSync(filepath, 'w'));
46-
core.info(`[INFO] Created ${filepath}`);
36+
const filepath = path.join(workDir, '.nojekyll');
37+
if (fs.existsSync(filepath)) {
38+
return;
4739
}
40+
fs.closeSync(fs.openSync(filepath, 'w'));
41+
core.info(`[INFO] Created ${filepath}`);
4842
}
4943

5044
export async function addCNAME(workDir: string, content: string): Promise<void> {

0 commit comments

Comments
 (0)