Skip to content

Commit

Permalink
feat: add postinstall script
Browse files Browse the repository at this point in the history
  • Loading branch information
vboechat committed May 21, 2024
1 parent 43f2718 commit 60d7a69
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/postinstall.ts
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.');
});

0 comments on commit 60d7a69

Please sign in to comment.