|
1 | 1 | const { execFileSync, spawnSync } = require('child_process');
|
2 | 2 | const { existsSync, readFileSync, statSync, writeFileSync } = require('fs');
|
3 | 3 | const { arch, platform } = require('os');
|
4 |
| -const { basename, dirname, join, resolve } = require('path'); |
| 4 | +const { dirname, join, resolve } = require('path'); |
5 | 5 | const { quote } = require('shell-quote');
|
6 | 6 |
|
7 | 7 | // Terminate early if this script is not invoked with the required arguments.
|
@@ -161,16 +161,19 @@ try {
|
161 | 161 | }
|
162 | 162 |
|
163 | 163 | packageJsonDirs.forEach((dir) => {
|
164 |
| - console.log(`Installing '@sap/cds-dk' into ${dir} to enable CDS compilation ...`); |
| 164 | + console.log(`Installing node dependencies from ${dir}/package.json ...`); |
165 | 165 | execFileSync(
|
166 | 166 | 'npm',
|
167 |
| - ['install', '--quiet', '--no-audit', '--no-fund', '--no-save', '@sap/cds-dk'], |
| 167 | + ['install', '--quiet', '--no-audit', '--no-fund'], |
168 | 168 | { cwd: dir, stdio: 'inherit' }
|
169 | 169 | );
|
170 |
| - console.log(`Installing node packages into ${dir} to enable CDS compilation ...`); |
| 170 | + // Order is important here. Install dependencies from package.json in the directory, |
| 171 | + // then install the CDS development kit (`@sap/cds-dk`) in the directory. Reversing |
| 172 | + // this order causes cyclic install-remove behavior. |
| 173 | + console.log(`Installing '@sap/cds-dk' into ${dir} to enable CDS compilation ...`); |
171 | 174 | execFileSync(
|
172 | 175 | 'npm',
|
173 |
| - ['install', '--quiet', '--no-audit', '--no-fund'], |
| 176 | + ['install', '--quiet', '--no-audit', '--no-fund', '--no-save', '@sap/cds-dk'], |
174 | 177 | { cwd: dir, stdio: 'inherit' }
|
175 | 178 | );
|
176 | 179 | });
|
@@ -201,7 +204,7 @@ responseFiles.forEach(rawCdsFilePath => {
|
201 | 204 | '--locations',
|
202 | 205 | '--log-level', 'warn'
|
203 | 206 | ],
|
204 |
| - { cwd: dirname(cdsFilePath), shell: true, stdio: 'pipe' } |
| 207 | + { shell: true, stdio: 'pipe' } |
205 | 208 | );
|
206 | 209 | if (result.error || result.status !== 0 || !result.stdout) {
|
207 | 210 | const errorMessage = `Could not compile the file ${cdsFilePath}.\nReported error(s):\n\`\`\`\n${result.stderr.toString()}\n\`\`\``;
|
|
0 commit comments