From 0cff4306efff29c0ae0ad82d981bf7d3cfe2403d Mon Sep 17 00:00:00 2001 From: Julian Waller Date: Sat, 4 Jun 2022 15:48:18 +0100 Subject: [PATCH] chore: use pkg-prebuilds --- .github/workflows/node.yaml | 4 +-- index.js | 52 +++++++++++++++++++------------------ package.json | 5 ++-- yarn.lock | 5 ++++ 4 files changed, 37 insertions(+), 29 deletions(-) diff --git a/.github/workflows/node.yaml b/.github/workflows/node.yaml index 128a768..519d99d 100644 --- a/.github/workflows/node.yaml +++ b/.github/workflows/node.yaml @@ -98,7 +98,7 @@ jobs: fi yarn rebuild --arch=${{ matrix.arch }} - yarn cmake-js-prebuildify --source build/Release/$BINDING_NAME.node --name=$BINDING_NAME --strip --napi_version=$NAPI_VERSION --arch=${{ matrix.arch }} + yarn pkg-prebuilds-copy --source build/Release/$BINDING_NAME.node --name=$BINDING_NAME --strip --napi_version=$NAPI_VERSION --arch=${{ matrix.arch }} env: CI: true npm_config_build_from_source: true @@ -129,7 +129,7 @@ jobs: yarn yarn test - yarn cmake-js-prebuildify --source build/Release/$BINDING_NAME.node --name=$BINDING_NAME --strip --napi_version=$NAPI_VERSION --arch=${{ matrix.arch }} --libc=${{ matrix.libc }} + yarn pkg-prebuilds-copy --source build/Release/$BINDING_NAME.node --name=$BINDING_NAME --strip --napi_version=$NAPI_VERSION --arch=${{ matrix.arch }} --libc=${{ matrix.libc }} - name: Upload artifacts uses: actions/upload-artifact@v3 diff --git a/index.js b/index.js index 5f377af..5032f7a 100644 --- a/index.js +++ b/index.js @@ -1,36 +1,38 @@ -var binding = require('cmake-js/bindings')(__dirname, require('./binding-options')) +var binding = require("pkg-prebuilds/bindings")( + __dirname, + require("./binding-options") +); // Copy exports so that we can customize them on the JS side without // overwriting the binding itself. -Object.keys(binding).forEach(function(key) { - module.exports[key] = binding[key] -}) +Object.keys(binding).forEach(function (key) { + module.exports[key] = binding[key]; +}); // Convenience wrapper for Buffer slicing. -module.exports.compressSync = function(buffer, optionalOutBuffer, options) { - var out = binding.compressSync(buffer, optionalOutBuffer, options) - return out.data.slice(0, out.size) -} +module.exports.compressSync = function (buffer, optionalOutBuffer, options) { + var out = binding.compressSync(buffer, optionalOutBuffer, options); + return out.data.slice(0, out.size); +}; // Convenience wrapper for Buffer slicing. -module.exports.compress = function(a,b,c) { - return binding.compress(a,b,c).then(out => { - return out.data.slice(0, out.size) - }) -} - +module.exports.compress = function (a, b, c) { + return binding.compress(a, b, c).then((out) => { + return out.data.slice(0, out.size); + }); +}; // Convenience wrapper for Buffer slicing. -module.exports.decompressSync = function(buffer, optionalOutBuffer, options) { - var out = binding.decompressSync(buffer, optionalOutBuffer, options) - out.data = out.data.slice(0, out.size) - return out -} +module.exports.decompressSync = function (buffer, optionalOutBuffer, options) { + var out = binding.decompressSync(buffer, optionalOutBuffer, options); + out.data = out.data.slice(0, out.size); + return out; +}; // Convenience wrapper for Buffer slicing. -module.exports.decompress = function(a,b,c) { - return binding.decompress(a,b,c).then(out => { - out.data = out.data.slice(0, out.size) - return out - }) -} +module.exports.decompress = function (a, b, c) { + return binding.decompress(a, b, c).then((out) => { + out.data = out.data.slice(0, out.size); + return out; + }); +}; diff --git a/package.json b/package.json index e641299..78f7670 100644 --- a/package.json +++ b/package.json @@ -24,10 +24,11 @@ "types": "./module.d.ts", "dependencies": { "cmake-js": "7.0.0-1", - "node-addon-api": "^5.0.0" + "node-addon-api": "^5.0.0", + "pkg-prebuilds": "^0.0.2" }, "scripts": { - "install": "cmake-js-verify ./binding-options.js || cmake-js compile --target jpeg-turbo", + "install": "pkg-prebuilds-verify ./binding-options.js || cmake-js compile --target jpeg-turbo", "rebuild": "cmake-js rebuild --target jpeg-turbo", "test": "jest" }, diff --git a/yarn.lock b/yarn.lock index dad9d26..b3e2f5d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1996,6 +1996,11 @@ pkg-dir@^4.2.0: dependencies: find-up "^4.0.0" +pkg-prebuilds@^0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/pkg-prebuilds/-/pkg-prebuilds-0.0.2.tgz#1f4f5dc26a3043c7dcf39fc7aa79fff4389df97a" + integrity sha512-gsjn9BkOCZtAyCgC96zkGkODgTEy9+31zNGL7Tk2ODx5w2O+fc90rDzX9PWEbGNy6iRRzK3opLKmfZhwQN5uOQ== + pretty-format@^28.1.0: version "28.1.0" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-28.1.0.tgz#8f5836c6a0dfdb834730577ec18029052191af55"