Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
npm.load(this.config, function npmConfigLoaded(error) {
if (error) return void callback(error);
//
// Temporary hack to add custom headers to the npm-registry-client.
// TODO: remove this hack once headers can be specified through load/config.
//
const _authify = npm.registry.authify;
npm.registry.authify = function authify(authed, parsed, headers, credentials) {
//
// Setup header for install in provided environment.
//
headers['registry-environment'] = self.env;
return _authify.call(npm.registry, authed, parsed, headers, credentials);
};
return void npm[cmd](self.base, self.base, callback);
});
};
npm.registry.authify = function authify(authed, parsed, headers, credentials) {
//
// Setup header for install in provided environment.
//
headers['registry-environment'] = self.env;
return _authify.call(npm.registry, authed, parsed, headers, credentials);
};
npm.load(this.config, function npmConfigLoaded(error) {
if (error) return void callback(error);
//
// Temporary hack to add custom headers to the npm-registry-client.
// TODO: remove this hack once headers can be specified through load/config.
//
const _authify = npm.registry.authify;
npm.registry.authify = function authify(authed, parsed, headers, credentials) {
//
// Setup header for install in provided environment.
//
headers['registry-environment'] = self.env;
return _authify.call(npm.registry, authed, parsed, headers, credentials);
};
return void npm[cmd](self.base, self.base, callback);
});
};
npm.commands.pack(['./dist'], function (packError) {
if (packError) {
return callback(packError);
}
var fileName = metadata.name + '-' + metadata.version + '.tgz';
var bodyPath = require.resolve('./' + fileName);
var body = fs.createReadStream(bodyPath);
var publishParams = {
metadata: metadata,
access: 'public',
tag: 'next',
body: body,
auth: auth
};
npm.registry.publish(uri, publishParams, function (publishError, resp) {
if (publishError) {
return callback(publishError);
}
console.log("Publish succesfull: " + JSON.stringify(resp));
return callback();
});
})
});
npm.load({}, function(err) {
npm.registry.adduser(options.username, options.password, options.email, function (err) {
if (err) {
console.log(err);
done(false);
} else {
npm.config.set('email', options.email);
npm.commands.publish([], function (err) {
console.log(err || 'Published to npm.');
done(!err);
});
}
});
});
});
npm.load({}, function() {
npm.registry.adduser(
options.username,
options.password,
options.email,
function(err) {
if (err) {
console.log(err);
done(false);
} else {
npm.config.set('email', options.email);
npm.commands.publish([], function(err) {
console.log(err || 'Published to npm.');
done(!err);
});
}
}
npm.load({}, function(err) {
if (err) {
console.log(err);
return done(err);
}
npm.registry.adduser(process.env.NPM_USERNAME, process.env.NPM_PASSWORD, process.env.NPM_EMAIL, function(err) {
if (err) {
console.log(err);
return done(err);
}
npm.config.set("email", process.env.NPM_EMAIL, "user");
npm.commands.publish([paths.dist], function(err) {
if (err) {
console.log(err);
return done(err);
}
console.log(paths.dist + " v" + pkg.verison + " Published to registry");
return done();
});
npm.load(null, function (loadError) {
if (loadError) {
return callback(loadError);
}
var auth = {
username: username,
password: password,
email: email,
alwaysAuth: true
};
var addUserParams = {
auth: auth
};
npm.registry.adduser(uri, addUserParams, function (addUserError, data, raw, res) {
if (addUserError) {
return callback(addUserError);
}
var metadata = require('./dist/package.json');
metadata = JSON.parse(JSON.stringify(metadata));
npm.commands.pack(['./dist'], function (packError) {
if (packError) {
return callback(packError);
}
var fileName = metadata.name + '-' + metadata.version + '.tgz';
var bodyPath = require.resolve('./' + fileName);
var body = fs.createReadStream(bodyPath);
var publishParams = {
metadata: metadata,
access: 'public',
}, function (er) {
npm.commands.install(program.args || [], function (er, data) {
if(er)throw er;
});
npm.registry.log.on("log", function (message) {});
});
}else{
npm.load(config, function(){
npm.registry.log.level = config.loglevel;
npm.commands.install(temp.dir, [options.module], function(err, data){
if (err) {
cbk(err, data);
} else {
var dir = temp.dir + "/node_modules/" + options.module;
var mod = require(dir);
cbk(void 0, mod);
}
});
});
}