-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
20 additions
and
0 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,20 @@ | ||
import { execSync } from 'child_process'; | ||
import { platform as _platform, arch as _arch } from 'os'; | ||
import { handleError } from './lib/error-handler'; | ||
|
||
const platform = _platform(); | ||
const arch = _arch(); | ||
|
||
const lookupTable: { [key: string]: string } = { | ||
'win32-x64': 'npm install --os=win32 --cpu=x64 sharp', | ||
'linux-x64': 'npm install --os=linux --cpu=x64 sharp', | ||
'darwin-x64': 'npm install --os=darwin --cpu=x64 sharp' | ||
}; | ||
|
||
const key = `${platform}-${arch}`; | ||
const command = lookupTable[key] || 'npm install sharp'; | ||
|
||
handleError(() => { | ||
execSync(command, { stdio: 'inherit' }); | ||
console.log('Sharp successfully installed.'); | ||
}); |