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

jspm-npm

Package Overview
Dependencies
Maintainers
1
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jspm-npm - npm Package Compare versions

Comparing version 0.0.3 to 0.1.0

53

npm.js

@@ -14,3 +14,3 @@ var request = require('request');

var nodeBuiltins = ['assert', 'child_process', 'dgram', 'events', 'fs', 'https', 'net', 'path', 'process', 'querystring',
'stream', 'string_decoder', 'sys', 'timers', 'tls', 'tty', 'url', 'util'];
'stream', 'string_decoder', 'sys', 'timers', 'tls', 'tty', 'url', 'util', 'http'];

@@ -99,26 +99,39 @@ var NPMLocation = function(options) {

if (v.substr(0, 1) == '~')
replaceMap[d] = 'npm:' + d + '@' + v.substr(1).split('.').splice(0, 2).join('.');
replaceMap['npm:' + d] = 'npm:' + d + '@' + v.substr(1).split('.').splice(0, 2).join('.');
else if (v.match(exactVersionRegEx))
replaceMap[d] = 'npm:' + d + '@' + v;
replaceMap['npm:' + d] = 'npm:' + d + '@' + v;
else
replaceMap[d] = 'npm:' + d;
replaceMap['npm:' + d] = 'npm:' + d;
}
for (var i = 0; i < nodeBuiltins.length; i++)
replaceMap[nodeBuiltins[i]] = 'npm:' + nodeBuiltins[i];
pjson.dependencyMap = replaceMap;
pjson.map = replaceMap;
pjson.format = 'cjs';
if (pjson.main) {
if (pjson.main.substr(0, 2) == './')
pjson.main = pjson.main.substr(2);
if (pjson.main.substr(pjson.main.length - 3, 3) == '.js')
pjson.main = pjson.main.substr(0, pjson.main.length - 3);
}
pjson.buildConfig = pjson.buildConfig || {};
pjson.buildConfig.uglify = pjson.buildConfig.uglify === undefined ? true : pjson.buildConfig.uglify;
// save back the package.json for further processing
fs.writeFile(dir + path.sep + 'package.json', JSON.stringify(pjson, null, 2), function(err) {
// glob all the js files and make jspm-compatible
glob(dir + '/**/*.js', function(err, files) {
if (err)
return errback(err);
callback();
if (!files.length)
return callback(pjson);
var doneCnt = 0;
for (var i = 0; i < files.length; i++)
convertRequires(files[i], function() {
doneCnt++;
if (doneCnt == files.length)
callback(pjson);
}, errback);
});
});

@@ -128,4 +141,5 @@ }

var cjsRequireRegEx = /require\s*\(\s*("([^"]+)"|'([^']+)')\s*\)/g;
var replaceRequires = function(file, replaceMap, callback, errback) {
var convertRequires = function(file, callback, errback) {
// replace require('some-module/here') with require('some-module@1.1/here')
var changed = false;
fs.readFile(file, function(err, data) {

@@ -136,4 +150,10 @@ data = data + '';

var name = singleString || doubleString;
if (replaceMap[name])
return reqName.replace(name, replaceMap[name]);
if (name.substr(name.length - 3, 3) == '.js') {
changed = true;
return reqName.replace(name, name.substr(0, name.length - 3));
}
else if (name.substr(0, 1) != '.') {
changed = true;
return reqName.replace(name, 'npm:' + name);
}
else

@@ -143,2 +163,5 @@ return reqName;

if (!changed)
return callback();
fs.writeFile(file, data, function(err) {

@@ -145,0 +168,0 @@ if (err)

{
"name": "jspm-npm",
"version": "0.0.3",
"version": "0.1.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "npm.js",

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