@sap/cds-dk 4.5.3 → 4.5.4

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.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
7
  The format is based on [Keep a Changelog](http://keepachangelog.com/).
8
8
 
9
+ ## Version 4.5.4 - 2021-10-07
10
+
11
+ ### Fixed
12
+
13
+ - `cds watch` no longer fails if started with `--ext`, `--livereload`, or `--open` arguments
14
+
9
15
  ## Version 4.5.3 - 2021-10-05
10
16
 
11
17
  ### Fixed
package/bin/watch.js CHANGED
@@ -1,6 +1,7 @@
1
+ const watchOnlyOptions = ['--ext', '--livereload', '--open']
1
2
  module.exports = Object.assign ( watch, {
2
3
  flags: [ '--debug', '--in-memory', '--in-memory?' ],
3
- options: [ '--port', '--ext', '--livereload', '--open' ],
4
+ options: [ '--port', ...watchOnlyOptions ],
4
5
  help: `
5
6
  # SYNOPSIS
6
7
 
@@ -61,15 +62,16 @@ async function watch ([cwd], {
61
62
  ext = extDefaults,
62
63
  ...options
63
64
  }={}) {
64
-
65
65
  args.push (`--${Object.keys(options).find(a => /^in-memory\??$/.test(a)) || 'in-memory?'}`)
66
- args.push (...process.argv.slice(3).filter(a => a !== cwd))
66
+ args.push (...process.argv.slice(3)
67
+ .filter(removeArgsIn(watchOnlyOptions)) // remove all watch-only options, as `cds serve` would not accept them
68
+ .filter(a => a !== cwd))
69
+
67
70
  const env = Object.assign (process.env, {
68
71
  _args: JSON.stringify(args),
69
72
  _options: JSON.stringify(options)
70
73
  })
71
74
  if (typeof ext !== 'string') ext = extDefaults
72
- if ('port' in options) env.PORT = options.port
73
75
  env.NODE_PATH = path.resolve (__dirname,'../node_modules') // allow global sqlite to be resolved
74
76
 
75
77
  let liveReload //= ...
@@ -143,7 +145,20 @@ const FileHandlers = {
143
145
  },
144
146
  }
145
147
 
146
-
148
+ function removeArgsIn (toRemove) {
149
+ let argRemoved = false
150
+ return arg => { // filter function
151
+ if (toRemove.includes(arg)) {
152
+ argRemoved = true
153
+ return false
154
+ }
155
+ else if (argRemoved) { // if next arg is a value, skip it as well
156
+ argRemoved = false
157
+ if (!arg.startsWith('-')) return false
158
+ }
159
+ return true
160
+ }
161
+ }
147
162
 
148
163
  //
149
164
  // Child process impl launched by watch