mirror of
https://github.com/laurent22/joplin.git
synced 2026-03-13 08:09:59 +08:00
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { exists, mkdir, readFile, remove } from 'fs-extra';
|
||||
import { exists, mkdir, readFile, remove, writeFile } from 'fs-extra';
|
||||
import { join } from 'path';
|
||||
import htmlpack from '.';
|
||||
|
||||
@@ -32,4 +32,25 @@ describe('htmlpack/index', () => {
|
||||
</body>
|
||||
</html>`);
|
||||
});
|
||||
|
||||
test('should not throw when a script asset is missing', async () => {
|
||||
const inputFile = join(outputDirectory, 'input.html');
|
||||
const outputFile = join(outputDirectory, 'output.html');
|
||||
|
||||
const inputHtml = `
|
||||
<html>
|
||||
<head>
|
||||
<script type="application/javascript" src="missing-script.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>Test</p>
|
||||
</body>
|
||||
</html>`;
|
||||
|
||||
await writeFile(inputFile, inputHtml, 'utf8');
|
||||
await htmlpack(inputFile, outputFile);
|
||||
|
||||
const outputContent = await readFile(outputFile, 'utf8');
|
||||
expect(outputContent).toContain('<p>Test</p>');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -132,6 +132,7 @@ const packToString = async (baseDir: string, inputFileText: string, fs: FileApi)
|
||||
if (!src) return null;
|
||||
|
||||
const scriptFilePath = `${baseDir}/${src}`;
|
||||
if (!await fs.exists(scriptFilePath)) return null;
|
||||
let content = await fs.readFileText(scriptFilePath);
|
||||
|
||||
// There's no simple way to insert arbitrary content in <script> tags.
|
||||
|
||||
Reference in New Issue
Block a user