Skip to content

Commit

Permalink
fix(template-webpack): properly remove stylesheet link from index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
malept committed Jul 15, 2019
1 parent 5b58606 commit 89176b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/api/core/test/slow/api_spec_slow.ts
Expand Up @@ -108,7 +108,7 @@ describe(`electron-forge API (with installer=${nodeInstaller})`, () => {
});
});

describe.only('init (with built-in templater)', () => {
describe('init (with built-in templater)', () => {
before(ensureTestDirIsNonexistent);

it('should succeed in initializing', async () => {
Expand Down Expand Up @@ -144,7 +144,11 @@ describe(`electron-forge API (with installer=${nodeInstaller})`, () => {
it('should move and rewrite the main process file', async () => {
await expectProjectPathNotExists(path.join('src', 'index.js'), 'file');
await expectProjectPathExists(path.join('src', 'main.js'), 'file');
expect(await fs.readFile(path.join(dir, 'src', 'main.js'))).to.match(/MAIN_WINDOW_WEBPACK_ENTRY/);
expect((await fs.readFile(path.join(dir, 'src', 'main.js'))).toString()).to.match(/MAIN_WINDOW_WEBPACK_ENTRY/);
});

it('should remove the stylesheet link from the HTML file', async () => {
expect((await fs.readFile(path.join(dir, 'src', 'index.html'))).toString()).to.not.match(/link rel="stylesheet"/);
});

after(async () => {
Expand Down
5 changes: 5 additions & 0 deletions packages/template/webpack/src/WebpackTemplate.ts
Expand Up @@ -63,6 +63,11 @@ class WebpackTemplate implements ForgeTemplate {
if (line.includes('mainWindow.loadURL')) return ' mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY);';
return line;
}, path.resolve(directory, 'src', 'main.js'));

await updateFileByLine(path.resolve(directory, 'src', 'index.html'), (line) => {
if (line.includes('link rel="stylesheet"')) return '';
return line;
});
});
}
}
Expand Down

0 comments on commit 89176b4

Please sign in to comment.