summaryrefslogtreecommitdiff
path: root/node_modules/node-pre-gyp/lib/testpackage.js
diff options
context:
space:
mode:
author8cy <[email protected]>2020-04-03 02:37:42 -0700
committer8cy <[email protected]>2020-04-03 02:37:42 -0700
commit60867fb030bae582082340ead7dbc7efdc2f5398 (patch)
tree4c6a7356351be2e4914e15c4703172597c45656e /node_modules/node-pre-gyp/lib/testpackage.js
parentcommenting (diff)
downloads5nical-60867fb030bae582082340ead7dbc7efdc2f5398.tar.xz
s5nical-60867fb030bae582082340ead7dbc7efdc2f5398.zip
2020/04/03, 02:34, v1.2.0
Diffstat (limited to 'node_modules/node-pre-gyp/lib/testpackage.js')
-rw-r--r--node_modules/node-pre-gyp/lib/testpackage.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/node_modules/node-pre-gyp/lib/testpackage.js b/node_modules/node-pre-gyp/lib/testpackage.js
new file mode 100644
index 0000000..9091bc3
--- /dev/null
+++ b/node_modules/node-pre-gyp/lib/testpackage.js
@@ -0,0 +1,55 @@
+"use strict";
+
+module.exports = exports = testpackage;
+
+exports.usage = 'Tests that the staged package is valid';
+
+var fs = require('fs');
+var path = require('path');
+var log = require('npmlog');
+var existsAsync = fs.exists || path.exists;
+var versioning = require('./util/versioning.js');
+var napi = require('./util/napi.js');
+var testbinary = require('./testbinary.js');
+var tar = require('tar');
+var mkdirp = require('mkdirp');
+
+function testpackage(gyp, argv, callback) {
+ var package_json = JSON.parse(fs.readFileSync('./package.json'));
+ var napi_build_version = napi.get_napi_build_version_from_command_args(argv);
+ var opts = versioning.evaluate(package_json, gyp.opts, napi_build_version);
+ var tarball = opts.staged_tarball;
+ existsAsync(tarball, function(found) {
+ if (!found) {
+ return callback(new Error("Cannot test package because " + tarball + " missing: run `node-pre-gyp package` first"));
+ }
+ var to = opts.module_path;
+ function filter_func(entry) {
+ log.info('install','unpacking [' + entry.path + ']');
+ }
+
+ mkdirp(to, function(err) {
+ if (err) {
+ return callback(err);
+ } else {
+ tar.extract({
+ file: tarball,
+ cwd: to,
+ strip: 1,
+ onentry: filter_func
+ }).then(after_extract, callback);
+ }
+ });
+
+ function after_extract() {
+ testbinary(gyp,argv,function(err) {
+ if (err) {
+ return callback(err);
+ } else {
+ console.log('['+package_json.name+'] Package appears valid');
+ return callback();
+ }
+ });
+ }
+ });
+}