UNPKG

@gravityforms/gulp-tasks

Version:
37 lines (28 loc) 1.31 kB
#!/usr/bin/env node const fs = require( 'fs' ); const path = require( 'path' ); const packageJsonPath = path.join( process.cwd(), 'package.json' ); const packageJson = require( packageJsonPath ); Object.keys( packageJson.dependencies ).forEach( ( dep ) => { if ( packageJson.dependencies[ dep ].startsWith( 'file:' ) && dep.startsWith( '@gravityforms/' ) ) { // Extract the folder name from the dependency const folderName = dep.split( '/' )[ 1 ]; // Construct the path to the package.json file in the directory two levels up from the script const targetPackageJsonPath = path.join( process.cwd(), '..', folderName, 'package.json' ); // Check if the package.json file exists if ( fs.existsSync( targetPackageJsonPath ) ) { // Require the package.json file to get the version number const targetPackageJson = require( targetPackageJsonPath ); // Update the version number in the current package.json packageJson.dependencies[ dep ] = `^${ targetPackageJson.version }`; } else { console.error( `Package.json not found at ${ targetPackageJsonPath }` ); } } } ); // Create a backup before writing changes fs.copyFileSync( packageJsonPath, path.join( process.cwd(), 'package.backup.json' ) ); fs.writeFileSync( packageJsonPath, JSON.stringify( packageJson, null, 2 ) );