Skip to content

afc163/cmdize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cmdize (deprecated)

Build Status NPM version David Status

Don't use it, write code in CommonJS, that is all.


Convert normal js to CMD module.(What is CMD module? 中文定义)

Support some famous JavaScript libraries(jQuery、underscore、momentjs) and no-dependencies JS Normal file.

It is a experimental project, be cautious to use it in important situation!

demo


Install

$ npm install cmdize -g

Use in cli

There is a js file exmple.js:

window.abc = "abc";

Cmdize it!

$ cmdize example.js
Reading /Users/afc163/Desktop/example.js ...
No found any global variables.
cmdized.js is generated.
  >> /Users/afc163/Projects/cmdize/example-cmdized.js

Then the cmdized.js would be generated at current path.

define(function(require, exports, module) {
window.abc = "abc";
});

Also support url.

$ cmdize http://code.jquery.com/jquery-1.10.1.js

Options

clearGlobal

$ cmdize example.js --clear-global

It will remove abc from window safely.

define(function(require, exports, module) {
window.abc = "abc";
try { delete window.abc } catch(e) { window.abc = null }
});

In NodeJS

var cmdize = require('cmdize');

cmdize(code, options, function(result) {
  // print cmdized code
  console.log(result);
});

Bitdeli Badge