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

alpaca-sm

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alpaca-sm - npm Package Compare versions

Comparing version 2.0.10 to 2.1.0

lib/base.js

4

index.js

@@ -17,7 +17,7 @@ var alp = module.exports = {};

alp.config = alp.conf || require('./lib/config.js');
alp.config = alp.config || require('./lib/config.js');
alp.File = require('./lib/file.js');
alp.processor = require('./lib/processor.js');
alp.processor = require('./lib/dispatcher.js');

@@ -25,3 +25,3 @@ var CONFIG = {

// js文件中的出现require()的路径是否是基于root的(主要用于应对使用构建工具生成的文件,路径会被编译为基于项目root的相对路径,如fis)
fileBasedRoot: false,
fileBasedRoot: true,

@@ -39,3 +39,3 @@ // 分析依赖时所识别的关键字

// 在HTML文件的script标签使用require('../xx.css')是,是否读取css的内容
// 在HTML文件的script标签使用require('../xx.css')是,是否读取css的内容 (已废弃)
cssInHTML: false

@@ -42,0 +42,0 @@ },

@@ -7,4 +7,2 @@ var _ = alp._;

function removeExt(url) {

@@ -55,7 +53,10 @@ return url.replace(/\.[\da-z]*$/i, '');

this.ns = config.get('ns');
if (this.isLikeCss || this.isLikeHtml) {
this.readable = config.get('readable.css') || config.get('readable.cssInHTML');
this.isWrapJSClosure = this.isJsFile;
if (this.isLikeCss) {
this.isCanembed = config.get('readable.css');
}
this.useCompile = _.filter1(absUrl, config.get('include'), config.get('exclude'));
this.mtime = this.getMtime();
}

@@ -85,2 +86,3 @@

}
this.md5 = _.md5(this._content);
return this._content;

@@ -95,2 +97,4 @@ },

this._content = content;
this.md5 = _.md5(content);
},

@@ -100,9 +104,2 @@ getMtime: function () {

},
buildMd5: function(content) {
if (typeof content === 'undefined') {
content = this.getRawContent();
}
this.md5 = _.md5(content);
return this.md5;
},
addRequire : function(id){

@@ -112,2 +109,3 @@ if(id && (id = id.trim())){

this.requires.push(id);
this.requiresObj[id] = 1;
}

@@ -118,2 +116,5 @@ return id;

},
existsRequire: function (id) {
return id in this.requiresObj;
},
removeRequire: function(id){

@@ -123,2 +124,3 @@ var pos = this.requires.indexOf(id);

this.requires.splice(pos, 1);
delete this.requiresObj[id];
}

@@ -130,2 +132,3 @@ },

this.aRequires.push(id);
}

@@ -140,2 +143,3 @@ return id;

this.aRequires.splice(pos, 1);
}

@@ -142,0 +146,0 @@ }

var colors = require('colors');
var ep = module.exports = {};
function log(type, msg) {
function getLine(loc) {
if (loc && loc.start && loc.end) {
if (loc.start.line == loc.end.line) {
return '[' + loc.start.line + ':' + loc.start.column + ']';
}
}
return '';
}
function log(type, msg, loc) {
if (type) {
type = '\n[' + type.toLocaleUpperCase() + '][ALPACA-SM]';
}
process.stdout.write(type + msg + '\n');
process.stdout.write(type + msg + getLine(loc) + '\n');
}
ep.error = function(err) {
ep.error = function(err, loc) {
if (!(err instanceof Error)) {

@@ -18,16 +25,10 @@ err = new Error(err.message || err);

log('error', err.message.red);
log('error', err.message.red, loc || {});
process.exit(1);
}
ep.warning = function(msg) {
log('waring', msg.yellow);
ep.warning = function(msg, loc) {
log('waring', msg.yellow, loc);
}
ep.info = function(msg) {
log('', msg.green);
}
ep.debug = function(msg){
log('debug',msg.blue);
}
ep.getLine = getLine;

@@ -488,3 +488,3 @@ var fs = require('fs');

}
patterns.every(function(pattern) {
patterns.every(function (pattern) {
if (!pattern) {

@@ -645,3 +645,40 @@ return true;

_.del = function(rPath, include, exclude){
var removedAll = true;
var path;
if(rPath && _.exists(rPath)) {
var stat = fs.lstatSync(rPath);
var isFile = stat.isFile() || stat.isSymbolicLink();
if (stat.isSymbolicLink()) {
path = rPath;
} else {
path = _.realpath(rPath);
}
if(/^(?:\w:)?\/$/.test(path)){
fis.log.error('unable to delete directory [' + rPath + '].');
}
if(stat.isDirectory()){
fs.readdirSync(path).forEach(function(name){
if(name != '.' && name != '..') {
removedAll = _.del(path + '/' + name, include, exclude) && removedAll;
}
});
if(removedAll) {
fs.rmdirSync(path);
}
} else if(isFile && _.filter1(path, include, exclude)) {
fs.unlinkSync(path);
} else {
removedAll = false;
}
} else {
//fis.log.error('unable to delete [' + rPath + ']: No such file or directory.');
}
return removedAll;
};
{
"name": "alpaca-sm",
"version": "2.0.10",
"version": "2.1.0",
"description": "分析Html文件依赖的js文件和css文件",

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

@@ -66,3 +66,3 @@ # alpaca-sm

####exclude
解释:排除一些已存在的使用require关键字的文件,比如用webpack或browerify打包的文件。
解释:排除一些已存在的使用require关键字的文件,比如用webpack或browerify打包的文件
类型:array | string | RegExp

@@ -88,6 +88,7 @@ 默认值:[]

默认值:false
####readable.cssInHtml
####readable.cssInHtml(已废弃)
解释:在HTML文件的script标签使用require('../xx.css')是,是否读取css的内容
类型:boolean
默认值:false
####tmpl

@@ -94,0 +95,0 @@ 解释:css和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