Skip to content

Commit 9863503

Browse files
committed
Test for writable package.json
1 parent cf01d65 commit 9863503

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/package.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ function isHostTrusted(url: url.UrlWithStringQuery): boolean {
210210
return TrustedSVGSources.indexOf(url.host.toLowerCase()) > -1 || isGitHubBadge(url.href);
211211
}
212212

213-
class ManifestProcessor extends BaseProcessor {
213+
export class ManifestProcessor extends BaseProcessor {
214214
constructor(manifest: Manifest) {
215215
super(manifest);
216216

src/test/package.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
WebExtensionProcessor,
1414
IAsset,
1515
IPackageOptions,
16+
ManifestProcessor,
1617
} from '../package';
1718
import { Manifest } from '../manifest';
1819
import * as path from 'path';
@@ -1684,6 +1685,21 @@ describe('toContentTypes', () => {
16841685
});
16851686
});
16861687

1688+
describe('ManifestProcessor', () => {
1689+
it('should ensure that package.json is writable', async () => {
1690+
const root = fixture('uuid');
1691+
const manifest = JSON.parse(await readFile(path.join(root, 'package.json'), 'utf8'));
1692+
const processor = new ManifestProcessor(manifest);
1693+
const packageJson = {
1694+
path: 'extension/package.json',
1695+
localPath: path.join(root, 'package.json'),
1696+
};
1697+
1698+
const outPackageJson = await processor.onFile(packageJson);
1699+
assert.ok(outPackageJson.mode & 0o200);
1700+
});
1701+
});
1702+
16871703
describe('MarkdownProcessor', () => {
16881704
it('should throw when no baseContentUrl is provided', async () => {
16891705
const manifest = {

0 commit comments

Comments
 (0)