diff --git a/isArray.md b/isArray.md new file mode 100644 index 0000000..d53cdce --- /dev/null +++ b/isArray.md @@ -0,0 +1,75 @@ +# Deprecation isArray Fix + +## Identify the Deprecation Warning + +- The `DeprecationWarning: The util.isArray API is deprecated` occurs due to the usage of `util.isArray` in certain libraries. + +## Fork the Library on GitHub + +- Fork the affected library's repository to your GitHub account (e.g., `git@github.com:YourUsername/library.git`) to make necessary modifications.**** + +## Clone and Modify the Fork + +- Clone the fork to your local machine and replace the deprecated `util.isArray` with `Array.isArray` in the relevant files. + + Example change: + + ```js + // Original code + var isArray = require('util').isArray; + + // Modified code + var isArray = Array.isArray; + ``` + +## Create a Patch for the Fix + +- Use `patch-package` to create a patch after modifying the code. This allows the fix to be reapplied after each package installation. + +### Install patch-package + +- Run the following command: + + ```bash + npm install patch-package postinstall-postinstall + ``` + +### Apply the Fix with patch-package + +- Create and apply the patch with: + + ```bash + npx patch-package library + ``` + +### Set postinstall Script + +- Add a postinstall script in `package.json` to ensure the patch is reapplied automatically: + + ```json + "scripts": { + "postinstall": "patch-package" + } + ``` + +## Install Dependencies + +- Run `npm install` to apply the patch and install the necessary dependencies. + +## Update Package Dependency + +- Modify your project's `package.json` to use the forked version of the library: + + ```json + "dependencies": { + "connect-flash": "git+ssh://git@github.com:YourUsername/library.git" + } + ``` + +## Install the Forked Version + +- Execute `npm install` to install the library from your forked repository. + +## Test the Fix + +- Ensure the deprecation warning is resolved and your application runs without any issues. diff --git a/lib/flash.js b/lib/flash.js index a278bc1..26de823 100644 --- a/lib/flash.js +++ b/lib/flash.js @@ -2,8 +2,7 @@ * Module dependencies. */ var format = require('util').format; -var isArray = require('util').isArray; - +var isArray = Array.isArray; /** * Expose `flash()` function on requests. @@ -14,7 +13,7 @@ var isArray = require('util').isArray; module.exports = function flash(options) { options = options || {}; var safe = (options.unsafe === undefined) ? true : !options.unsafe; - + return function(req, res, next) { if (req.flash && safe) { return next(); } req.flash = _flash; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..cffeeaa --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,38 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + devDependencies: + vows: + specifier: 0.6.x + version: 0.6.4 + +packages: + + diff@1.0.8: + resolution: {integrity: sha512-1zEb73vemXFpUmfh3fsta4YHz3lwebxXvaWmPbFv9apujQBWDnkrPDLXLQs1gZo4RCWMDsT89r0Pf/z8/02TGA==} + engines: {node: '>=0.3.1'} + + eyes@0.1.8: + resolution: {integrity: sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ==} + engines: {node: '> 0.1.90'} + + vows@0.6.4: + resolution: {integrity: sha512-CnnxhTuz08RHlAEagUSH6806IMxlOvYK5Nz5CyRGaqk9m2qVsP/0vtNBtU9rUS0TTrx3JYmPtHwIELaf+91t0Q==} + hasBin: true + +snapshots: + + diff@1.0.8: {} + + eyes@0.1.8: {} + + vows@0.6.4: + dependencies: + diff: 1.0.8 + eyes: 0.1.8