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

kmc

Package Overview
Dependencies
Maintainers
2
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kmc - npm Package Compare versions

Comparing version 1.0.19 to 1.0.20

examples/alias.js

7

HISTORY.md

@@ -0,1 +1,8 @@

## 2013.11.22, Version 1.0.20(Stable)
### enhancement
- 添加对KISSY 1.3+ 新包配置(对象配置)格式的支持
- issue #34: 增加alias配置支持
## 2013.11.09, Version 1.0.19(Stable)

@@ -2,0 +9,0 @@

@@ -211,2 +211,25 @@ /**

};
Compiler.prototype._alias = function(modName){
var self = this;
if(self.config.modules && self.config.modules[modName]){
var modConfig = self.config.modules[modName];
if(modConfig.alias){
var modNew = {
name: modConfig.alias,
path: '',
pkg: self._getModuleNameFromRequire(modConfig.alias)
};
if(modNew.pkg && self.config.pkgs[modNew.pkg]){
var modPkg = self.config.pkgs[modNew.pkg];
var dir = modPkg.ignorePackageNameInUri ? path.resolve(modPkg.path, '../') : modPkg.path;
modNew.path = path.resolve(dir, utils.addPathSuffix(modNew.name));
if(fs.existsSync(modNew.path)){
modNew.pkg = modPkg;
return modNew;
}
}
}
}
return null;
};

@@ -264,2 +287,8 @@ Compiler.prototype.getAst = getAst;

modName = self._mapModuleName(modName);
var modAlias = self._alias(modName);
if(modAlias){
modName = modAlias.name;
modPkg = modAlias.pkg;
modRealPath = modAlias.path;
}
if(_.indexOf(self.fileList, modRealPath) === -1){

@@ -266,0 +295,0 @@ // to avoid recursive analyze.

@@ -30,3 +30,8 @@ /**

config.pkgs = config.pkgs || {};
var isArrayFormat = _.isArray(cfg.packages);
_.forEach(cfg.packages, function(pkg, index){
if(!isArrayFormat){
pkg.name = index;
pkg.path = pkg.base;
}
if(_.isUndefined(pkg.charset)){

@@ -33,0 +38,0 @@ // if left blank, node will treat it as utf-8

2

package.json
{
"name":"kmc",
"version":"1.0.19",
"version":"1.0.20",
"description":"KISSY Module Compiler",

@@ -5,0 +5,0 @@ "author":"daxingplay <daxingplay@gmail.com>",

@@ -862,2 +862,71 @@ /**

describe('When use KISSY 1.3+ package format', function(){
var config;
before(function(){
config = ModuleCompiler.config({
packages: {
'package1': {
base: srcPath
}
},
silent: true
});
});
after(function(){
ModuleCompiler.clean();
});
it('should have proper config.', function(){
config.pkgs.should.have.property('package1');
});
});
describe('When alias was configured', function(){
var result;
var inputFile = path.resolve(srcPath, 'package1/alias.js'),
outputFile = path.resolve(distPath, 'package1/alias.js');
before(function(){
ModuleCompiler.config({
packages: [{
name: 'package1',
path: srcPath
}],
modules: {
'package1/mods/mod2': {
alias: 'package1/mods/mod3'
}
},
silent: true
});
result = ModuleCompiler.build(inputFile, outputFile);
});
after(function(){
ModuleCompiler.clean();
});
it('should use the name of mod3.', function(){
var mod = result.files[0];
var dep = mod.dependencies[0];
var depModName = dep.name;
depModName.should.equal('package1/mods/mod3');
});
it('should contain mod3 contents.', function(){
var outputContent = fs.readFileSync(outputFile);
/\[mod3/.test(outputContent).should.equal(true);
});
it('should not contain mod2 contents', function(){
var outputContent = fs.readFileSync(outputFile);
/\[mod2/.test(outputContent).should.equal(false);
});
});
//describe('When build a directory and have ignore config', function(){

@@ -864,0 +933,0 @@ // var result;

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