-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathmanifest.js
More file actions
21 lines (16 loc) · 816 Bytes
/
manifest.js
File metadata and controls
21 lines (16 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { readdirSync, readFileSync, writeFileSync } from 'fs'
import { resolve } from 'path';
const isChrome = process.env.BROWSER === undefined ? true : process.env.BROWSER === 'chrome';
if (!isChrome) {
const files = readdirSync(process.cwd() + '/dist');
files.forEach(file => {
if (file.includes('.js') && /\.js$/gi.test(file)) {
const content = readFileSync(resolve(process.cwd(), 'dist', file), 'utf8');
const rep = content.replace(/chrome\./g, 'browser.');
const reps = rep.replace(/chrome\.action|browser.action/g, 'browser.browserAction');
writeFileSync(resolve(process.cwd(), 'dist', file), reps);
}
});
const content = readFileSync(resolve(process.cwd(), 'manifest-v2.json'), 'utf8');
writeFileSync(resolve(process.cwd(), 'dist', 'manifest.json'), content);
}