-
Notifications
You must be signed in to change notification settings - Fork 580
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add script for optional mac dependencies
- Loading branch information
Showing
3 changed files
with
62 additions
and
6 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const os = require('os'); | ||
const fs = require('fs'); | ||
const { execSync } = require('child_process'); | ||
const path = require('path'); | ||
|
||
// Configuration: Array of packages to handle conditionally | ||
const packages = [ | ||
'node-mac-permissions', | ||
// Add more packages here if needed | ||
]; | ||
|
||
const isMac = os.platform() === 'darwin'; | ||
|
||
packages.forEach((packageName) => { | ||
const packagePath = path.join(__dirname, '..', 'node_modules', packageName); | ||
|
||
if (isMac) { | ||
// On macOS, ensure that the package is installed | ||
if (!fs.existsSync(packagePath)) { | ||
console.log(`macOS detected and ${packageName} is not installed. Installing...`); | ||
try { | ||
execSync(`npm install ${packageName}`, { stdio: 'inherit' }); | ||
console.log(`${packageName} installed successfully.`); | ||
} catch (error) { | ||
console.error(`Failed to install ${packageName} on macOS:`, error); | ||
process.exit(1); | ||
} | ||
} else { | ||
console.log(`macOS detected and ${packageName} is already installed. No action needed.`); | ||
} | ||
} else { | ||
// On non-macOS platforms, ensure that the package is not present | ||
if (fs.existsSync(packagePath)) { | ||
console.log(`Non-macOS platform detected and ${packageName} is present. Removing...`); | ||
try { | ||
execSync(`npm uninstall ${packageName}`, { stdio: 'inherit' }); | ||
console.log(`${packageName} removed successfully.`); | ||
} catch (error) { | ||
console.error(`Failed to uninstall ${packageName} on non-mac platform:`, error); | ||
process.exit(1); | ||
} | ||
} else { | ||
console.log(`Non-macOS platform detected and ${packageName} is not installed. No action needed.`); | ||
} | ||
} | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -29,7 +29,7 @@ | |
"buildPackges": "npx lerna run build", | ||
"packages": "npx lerna publish --no-git-tag-version", | ||
"uidev": "cd uidev && webpack-dev-server", | ||
"postinstall": "npx lerna run prepare" | ||
"postinstall": "npx lerna run prepare && node ./build-helpers/ensure-mac-dependency.js" | ||
}, | ||
"keywords": [], | ||
"author": "Stefan Malzner <[email protected]>", | ||
|