Skip to content

Commit

Permalink
chore: use pkg-prebuilds
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Jun 4, 2022
1 parent 4e5945a commit 0cff430
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
52 changes: 27 additions & 25 deletions index.js
Original file line number Diff line number Diff line change
@@ -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;
});
};
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 0cff430

Please sign in to comment.