@dcloudio/uni-cli-shared 2.0.1-33420211228002 → 2.0.1-33420211228004

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/package.js +20 -14
  2. package/package.json +2 -2
package/lib/package.js CHANGED
@@ -1,14 +1,11 @@
1
1
  const uniI18n = require('@dcloudio/uni-cli-i18n')
2
2
 
3
- const PLATFORMS = [
4
- 'h5',
5
- 'app-plus',
6
- 'mp-weixin',
7
- 'mp-qq',
8
- 'mp-baidu',
9
- 'mp-alipay',
10
- 'mp-toutiao'
11
- ]
3
+ function isPlainObject (a) {
4
+ if (a === null) {
5
+ return false
6
+ }
7
+ return typeof a === 'object'
8
+ }
12
9
 
13
10
  module.exports = {
14
11
  initCustomScript (name, pkgPath) {
@@ -27,13 +24,22 @@ module.exports = {
27
24
  }
28
25
 
29
26
  if (!scriptOptions.env || !scriptOptions.env.UNI_PLATFORM) {
30
- console.error(uniI18n.__('cliShared.requireConfigUniPlatform', { 0: `package.json->uni-app->scripts->${name}->env ` }))
27
+ console.error(uniI18n.__('cliShared.requireConfigUniPlatform', {
28
+ 0: `package.json->uni-app->scripts->${name}->env `
29
+ }))
31
30
  process.exit(0)
32
31
  }
33
32
 
34
- if (PLATFORMS.indexOf(scriptOptions.env.UNI_PLATFORM) === -1) {
35
- console.error(uniI18n.__('cliShared.supportPlatform', { 0: 'UNI_PLATFORM', 1: JSON.stringify(PLATFORMS) }))
36
- process.exit(0)
33
+ if (isPlainObject(scriptOptions.define)) {
34
+ Object.keys(uniAppOptions.scripts).forEach(scriptName => {
35
+ if (scriptName !== name) {
36
+ const define = uniAppOptions.scripts[scriptName].define
37
+ Object.keys(define).forEach(name => {
38
+ define[name] = false
39
+ })
40
+ Object.assign(scriptOptions.define, define)
41
+ }
42
+ })
37
43
  }
38
44
 
39
45
  process.env.UNI_PLATFORM = scriptOptions.env.UNI_PLATFORM
@@ -44,4 +50,4 @@ module.exports = {
44
50
 
45
51
  return scriptOptions
46
52
  }
47
- }
53
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "2.0.1-33420211228002",
3
+ "version": "2.0.1-33420211228004",
4
4
  "description": "uni-cli-shared",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
@@ -23,5 +23,5 @@
23
23
  "postcss-urlrewrite": "^0.2.2",
24
24
  "strip-json-comments": "^2.0.1"
25
25
  },
26
- "gitHead": "638b12e8f1886590d8f16562c14240c354a66bb2"
26
+ "gitHead": "46925c288cdb3a955c9eb78de2972d94b2f8d249"
27
27
  }