Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

scrat-command-install

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scrat-command-install - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

61

index.js

@@ -10,7 +10,23 @@ /**

exports.usage = '[name] [options]';
exports.desc = 'init project';
exports.desc = 'install component modules';
exports.register = function(commander){
commander
.option('--save')
.option('-s, --save', 'save dependencies into json file', Boolean)
.action(function(){
var path = require('path');
var resolve = path.resolve;
var dirname = function(){
return resolve(this.dest, this.name.toLowerCase().split('/').join('-'), this.version);
};
var args = Array.prototype.slice.call(arguments);
var options = args.pop();
var name = args.shift();
if(name){
var pos = name.indexOf('@');
var version = '*';
if(pos > -1){
version = name.substring(pos + 1);
name = name.substring(0, pos);
}
}
var Installer = require('component-installer');

@@ -21,15 +37,40 @@ var installer = new Installer(process.cwd());

installer.remote('https://raw.github.com');
if(options.save || !name){
var conf = installer.path('component.json');
if(!fis.util.isFile(conf)){
fis.log.error('missing component.json');
}
}
if(name && options.save){
var json = installer.json();
json.dependencies = json.dependencies || {};
var write = function(){
json.dependencies[this.name] = this.version === 'master' ? '*' : this.version;
fis.util.write(conf, JSON.stringify(json, null, 4));
};
}
installer.on('package', function (pkg) {
console.log(' ➜ installing', pkg.name, pkg.version);
pkg.constructor.prototype.dirname = dirname;
if(name && options.save){
pkg.on('end', write);
pkg.on('exists', write);
}
pkg.on('error', onerror);
console.log(' ➜ ' + 'installing '.grey + pkg.name + '@'.yellow + pkg.version);
});
installer.install(function (err) {
console.log(this.config);
if(err){
console.error(err);
var onerror = function(err){
if(err.message === 'dns lookup failed'){
console.log(' ✗ ' + err.message.yellow);
} else {
//TODO move
console.log(' √ all done');
console.log(' ✗ ' + err.message.red);
}
});
};
if(name){
installer.installPackage(name, version);
} else {
installer.install(function(err){
});
}
});
};

2

package.json
{
"name" : "scrat-command-install",
"description" : "install component modules",
"version" : "0.0.1",
"version" : "0.0.2",
"author" : "fouber <fouber.NET@gmail.com>",

@@ -6,0 +6,0 @@ "engines" : {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc