forked from ionic-team/ionic-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprepublish.js
More file actions
executable file
·26 lines (19 loc) · 927 Bytes
/
prepublish.js
File metadata and controls
executable file
·26 lines (19 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env node
const path = require('path');
const replace = require('replace');
const pluginName = process.argv[2];
const pluginPath = path.join(__dirname, `../packages/${pluginName}`);
const plugin = require(pluginPath);
const pkg = require(path.join(pluginPath, 'package.json'));
const nameMatchStr = '__NAME__';
const versionMatchStr = '__VERSION__';
if (!plugin.name) {
throw new Error(`Plugin ${pluginName} MUST define and export a 'name' attribute`);
}
if (!plugin.version) {
throw new Error(`Plugin ${pluginName} MUST define and export a 'version' attribute`);
}
const replacePath = path.join(pluginPath, pkg.main);
const pluginVersion = process.env['IONIC_PREPUBLISH_PLUGIN_VERSION'] || pkg.version;
replace({ regex: nameMatchStr, replacement: pkg.name, paths: [replacePath], recursive: false });
replace({ regex: versionMatchStr, replacement: pluginVersion, paths: [replacePath], recursive: false });