mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Separate build script from install script #4458
The --build-from-source flag is now deprecated and will soon be removed along with the need to define an install script. This will remove a whole category of package manager warnings about install scripts and "built" dependencies. Most people don't need to build sharp from source, but for those that do, a suitable method is now something like: $ npm install package-that-depends-on-sharp $ npm explore sharp -- npm run build
This commit is contained in:
36
install/build.js
Normal file
36
install/build.js
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright 2013 Lovell Fuller and others.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const {
|
||||
useGlobalLibvips,
|
||||
globalLibvipsVersion,
|
||||
log,
|
||||
spawnRebuild,
|
||||
} = require('../lib/libvips');
|
||||
|
||||
log('Attempting to build from source via node-gyp');
|
||||
log('See https://sharp.pixelplumbing.com/install#building-from-source');
|
||||
|
||||
try {
|
||||
const addonApi = require('node-addon-api');
|
||||
log(`Found node-addon-api ${addonApi.version || ''}`);
|
||||
} catch (_err) {
|
||||
log('Please add node-addon-api to your dependencies');
|
||||
process.exit(1);
|
||||
}
|
||||
try {
|
||||
const gyp = require('node-gyp');
|
||||
log(`Found node-gyp ${gyp().version}`);
|
||||
} catch (_err) {
|
||||
log('Please add node-gyp to your dependencies');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (useGlobalLibvips(log)) {
|
||||
log(`Detected globally-installed libvips v${globalLibvipsVersion()}`);
|
||||
}
|
||||
|
||||
const status = spawnRebuild();
|
||||
if (status !== 0) {
|
||||
process.exit(status);
|
||||
}
|
||||
Reference in New Issue
Block a user