-
Notifications
You must be signed in to change notification settings - Fork 26
/
read-supported-versions.js
executable file
·44 lines (36 loc) · 1.11 KB
/
read-supported-versions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env node
/**
* Reads the supported versions of @ngrx/signals from the package.json and saves
* them into a file, which is then consumed by the integrations tests.
*/
const fs = require('fs');
const path = require('path');
const os = require('os');
// Define the path to the package.json file
const packageJsonPath = path.join(
__dirname,
'libs/ngrx-toolkit',
'package.json'
);
// Define the path for the output file
const outputPath = path.join(__dirname, 'versions.txt');
// Read the package.json file
fs.readFile(packageJsonPath, 'utf8', (err, data) => {
if (err) {
console.error('Error reading package.json:', err);
return;
}
// Parse the JSON content
const packageJson = JSON.parse(data);
// Extract dependencies
const peerDependencies = packageJson.peerDependencies;
if (!peerDependencies?.['@ngrx/signals']) {
throw new Error('Could not find @ngrx/signals in peerDependencies');
}
const versions =
peerDependencies['@ngrx/signals']
.split('||')
.map((version) => version.trim())
.join(os.EOL) + os.EOL;
fs.writeFileSync(outputPath, versions);
});