-
Notifications
You must be signed in to change notification settings - Fork 761
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for Node.js >= 12.20.0
As older npm versions doesn't support new package.json override field, we're simulating it for older npm versions before the npm package publish phase.
- Loading branch information
Showing
2 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* This script simulates `overrides` package.json field | ||
* in older npm versions that doesn't support it. | ||
* | ||
* Older versions of npm match the package overrides by name and version, | ||
* instead of just name (this is how new `override` package.json field works). | ||
*/ | ||
/* eslint-disable import/no-dynamic-require */ | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const rootPckg = require(path.join(__dirname, '..', 'package.json')); | ||
const apidomReferencePckgPath = path.join( | ||
__dirname, | ||
'..', | ||
'node_modules', | ||
'@swagger-api', | ||
'apidom-reference', | ||
'package.json' | ||
); | ||
const apidomReferencePckg = require(apidomReferencePckgPath); | ||
|
||
const { | ||
overrides: { '@swagger-api/apidom-reference': overrides }, | ||
} = rootPckg; | ||
const overridesList = Object.keys(overrides).filter((key) => key.startsWith('@swagger-api/')); | ||
|
||
overridesList.forEach((override) => { | ||
if (Object.hasOwn(apidomReferencePckg.dependencies, override)) { | ||
apidomReferencePckg.dependencies[override] = '=0.0.1'; | ||
} | ||
}); | ||
|
||
fs.writeFileSync(apidomReferencePckgPath, JSON.stringify(apidomReferencePckg, null, 2)); |