Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions platform/nativescript/hooks/before-checkForChanges.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
module.exports = function(hookArgs, $errors) {
const bundle =
hookArgs &&
hookArgs.checkForChangesOpts &&
hookArgs.checkForChangesOpts.projectChangesOptions &&
hookArgs.checkForChangesOpts.projectChangesOptions.bundle
if (!bundle) {
$errors.failWithoutHelp(
"Nativescript-vue doesn't work without --bundle option. Please specify --bundle option to the command and execute it again."
)
const { isBundleCheckRequired } = require('./helpers')

module.exports = function(hookArgs, $errors, $injector) {
const shouldCheckBundleOption = isBundleCheckRequired($injector)

if (shouldCheckBundleOption) {
const bundle =
hookArgs &&
hookArgs.checkForChangesOpts &&
hookArgs.checkForChangesOpts.projectChangesOptions &&
hookArgs.checkForChangesOpts.projectChangesOptions.bundle

if (!bundle) {
$errors.failWithoutHelp(
"Nativescript-vue doesn't work without --bundle option. Please specify --bundle option to the command and execute it again."
)
}
}
}
26 changes: 16 additions & 10 deletions platform/nativescript/hooks/before-watch.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
module.exports = function(hookArgs, $errors) {
const bundle =
hookArgs &&
hookArgs.config &&
hookArgs.config.appFilesUpdaterOptions &&
hookArgs.config.appFilesUpdaterOptions.bundle
if (!bundle) {
$errors.failWithoutHelp(
"Nativescript-vue doesn't work without --bundle option. Please specify --bundle option to the command and execute it again."
)
const { isBundleCheckRequired } = require('./helpers')

module.exports = function(hookArgs, $errors, $injector) {
const shouldCheckBundleOption = isBundleCheckRequired($injector)

if (shouldCheckBundleOption) {
const bundle =
hookArgs &&
hookArgs.config &&
hookArgs.config.appFilesUpdaterOptions &&
hookArgs.config.appFilesUpdaterOptions.bundle
if (!bundle) {
$errors.failWithoutHelp(
"Nativescript-vue doesn't work without --bundle option. Please specify --bundle option to the command and execute it again."
)
}
}
}
14 changes: 14 additions & 0 deletions platform/nativescript/hooks/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function isBundleCheckRequired($injector) {
try {
const $staticConfig = $injector.resolve('$staticConfig')
const version = $staticConfig && $staticConfig.version
const majorVersion = (version || '').split('.')[0]
// If the major version is not available, probably we are in some new version of CLI, where the staticConfig is not available
// So it definitely should work with bundle;
return !majorVersion || +majorVersion < 6
} catch (err) {
return false
}
}

module.exports.isBundleCheckRequired = isBundleCheckRequired