File tree Expand file tree Collapse file tree 3 files changed +47
-20
lines changed
platform/nativescript/hooks Expand file tree Collapse file tree 3 files changed +47
-20
lines changed Original file line number Diff line number Diff line change 1
- module . exports = function ( hookArgs , $errors ) {
2
- const bundle =
3
- hookArgs &&
4
- hookArgs . checkForChangesOpts &&
5
- hookArgs . checkForChangesOpts . projectChangesOptions &&
6
- hookArgs . checkForChangesOpts . projectChangesOptions . bundle
7
- if ( ! bundle ) {
8
- $errors . failWithoutHelp (
9
- "Nativescript-vue doesn't work without --bundle option. Please specify --bundle option to the command and execute it again."
10
- )
1
+ const { isBundleCheckRequired } = require ( './helpers' )
2
+
3
+ module . exports = function ( hookArgs , $errors , $injector ) {
4
+ const shouldCheckBundleOption = isBundleCheckRequired ( $injector )
5
+
6
+ if ( shouldCheckBundleOption ) {
7
+ const bundle =
8
+ hookArgs &&
9
+ hookArgs . checkForChangesOpts &&
10
+ hookArgs . checkForChangesOpts . projectChangesOptions &&
11
+ hookArgs . checkForChangesOpts . projectChangesOptions . bundle
12
+
13
+ if ( ! bundle ) {
14
+ $errors . failWithoutHelp (
15
+ "Nativescript-vue doesn't work without --bundle option. Please specify --bundle option to the command and execute it again."
16
+ )
17
+ }
11
18
}
12
19
}
Original file line number Diff line number Diff line change 1
- module . exports = function ( hookArgs , $errors ) {
2
- const bundle =
3
- hookArgs &&
4
- hookArgs . config &&
5
- hookArgs . config . appFilesUpdaterOptions &&
6
- hookArgs . config . appFilesUpdaterOptions . bundle
7
- if ( ! bundle ) {
8
- $errors . failWithoutHelp (
9
- "Nativescript-vue doesn't work without --bundle option. Please specify --bundle option to the command and execute it again."
10
- )
1
+ const { isBundleCheckRequired } = require ( './helpers' )
2
+
3
+ module . exports = function ( hookArgs , $errors , $injector ) {
4
+ const shouldCheckBundleOption = isBundleCheckRequired ( $injector )
5
+
6
+ if ( shouldCheckBundleOption ) {
7
+ const bundle =
8
+ hookArgs &&
9
+ hookArgs . config &&
10
+ hookArgs . config . appFilesUpdaterOptions &&
11
+ hookArgs . config . appFilesUpdaterOptions . bundle
12
+ if ( ! bundle ) {
13
+ $errors . failWithoutHelp (
14
+ "Nativescript-vue doesn't work without --bundle option. Please specify --bundle option to the command and execute it again."
15
+ )
16
+ }
11
17
}
12
18
}
Original file line number Diff line number Diff line change
1
+ function isBundleCheckRequired ( $injector ) {
2
+ try {
3
+ const $staticConfig = $injector . resolve ( '$staticConfig' )
4
+ const version = $staticConfig && $staticConfig . version
5
+ const majorVersion = ( version || '' ) . split ( '.' ) [ 0 ]
6
+ // If the major version is not available, probably we are in some new version of CLI, where the staticConfig is not available
7
+ // So it definitely should work with bundle;
8
+ return ! majorVersion || + majorVersion < 6
9
+ } catch ( err ) {
10
+ return false
11
+ }
12
+ }
13
+
14
+ module . exports . isBundleCheckRequired = isBundleCheckRequired
You can’t perform that action at this time.
0 commit comments