Browse files

Changes

  • Loading branch information...
1 parent e742684 commit 0c1fc68962954870b90db2de638755b1c0f5766c @meekgeek committed Apr 13, 2012
Showing with 120 additions and 29 deletions.
  1. +14 −8 README.md
  2. +106 −21 index.js
View
22 README.md
@@ -16,16 +16,22 @@ It is recommended to install mxmlc as a global module, so that you can call it f
$ [sudo] npm install mxmlc -g
-## Uage
+## Usage
-Specify the input FLV file and the optional output directory.
+Specify the input Actionscript file and the optional output directory.
- Usage: mxmlc [options]
+ Usage: index.js [options] [command]
+
+ Commands:
- Options:
+ init
+ Initializes and creates the mxmlc.properties file.
+
+ run
- -h, --help output usage information
- -V, --version output the version number
- -f, --file <path> FLV file path
- -o, --out [path] Output directory
+ Options:
+
+ -h, --help output usage information
+ -V, --version output the version number
+ -r, --release-build Create a release build
View
127 index.js
@@ -3,37 +3,122 @@ var prompt = require('prompt');
var program = require('commander');
var execFile = require('child_process').execFile;
var nconf = require('nconf');
+var src_file;
nconf.file({file:"mxmlc.properties"});
program
+ .version('0.0.3')
+ .option('-r, --release-build', "Create a release build")
+ .option('-o, --output <path>', "Output for file")
+
+program
.command('init')
- .action( function(env){
+ .description('Initializes and creates the mxmlc.properties file.')
+ .option('-k, --sdk <path>', "Directory to FLEX SDKs")
+ .option('-s, --source-path', "Source path")
+ .option('-o, --output-path', "Output path")
+ .option('-f, --source-file', "File to compilet")
+ .option('-l, --lib-path', "Add lib path")
+ .action( function(){
+ //set sdk
+ if( program.sdkDir ) {
+ nconf.set('sdkDir', program.sdkDir );
+ console.log('sdkDir set to: '+program.sdkDir+''.blue);
+ } else {
+ if( ! nconf.get('sdkDir') ) {
+ //prompt
+ console.log('sdkDir default set'.blue);
+ }
+ }
+
+ if( program.sourcePath ) {
+ nconf.set('sourcePath', program.sourcePath );
+ console.log('sourcePath set to: '+program.sourcePath+''.blue);
+ } else {
+ if( ! nconf.get('sourcePath') ) {
+ nconf.set('sourcePath', '');
+ console.log('sourcePath default set'.blue);
+ }
+ }
+
+ if( program.sourceFile ) {
+ nconf.set('sourceFile', program.sourceFile );
+ console.log('sourceFile set to: '+program.sourceFile+''.blue);
+ } else {
+ if( ! nconf.get('sourceFile') ) {
+ nconf.set('sourceFile', 'Main');
+ console.log('sourceFile default set'.blue);
+
+ }
+ }
+
+ if( program.libPath ) {
+ nconf.set('libPath', program.libPath );
+ console.log('libPath set to: '+program.libPath+''.blue);
+ } else {
+ if( ! nconf.get('libPath') ) {
+ nconf.set('libPath', "");
+ console.log('libPath default set'.blue);
+ }
+ }
+
+ function tryExit() {
+ nconf.save(function(err){
+ process.exit(0);
+ });
+ }
});
program
- .command('run')
+ .command('*')
+ .description('File to build')
.action( function(env){
+ build(env);
+ });
- var mxmlc = "/Applications/Adobe Flash Builder 4.5/sdks/flex_sdk_4.6.0.23201B/bin/mxmlc";
- var args = ["-compiler.include-libraries=libs",
- "-compiler.incremental=true",
- "-static-link-runtime-shared-libraries=true",
- "-debug=true",
- "-default-background-color=0xffffff",
- "-default-frame-rate=30",
- "-default-size=980,590",
- "-source-path=src",
- process.cwd()+"/src/Main.as",
- "-o=bin/Main.swf" ]
-
- execFile(mxmlc,args,function(err,stdout,stderr){
- if(err){console.log('error: '+err);}
- console.log('Done!');
- process.exit(0);
- })
+program.parse(process.argv);
- });
-program.parse(process.argv);
+function build(file) {
+
+ var mxmlc = "/Applications/Adobe Flash Builder 4.5/sdks/flex_sdk_4.6.0.23201B/bin/mxmlc";
+ var output = Boolean(!program.releaseBuild) ? "bin/"+file+".swf" : "release/"+file+".swf"
+ var args = ["-compiler.incremental=true",
+ //"-compiler.include-libraries=libs",
+ "-static-link-runtime-shared-libraries=true",
+ "-debug="+Boolean(!program.releaseBuild),
+ "-default-background-color=0xffffff",
+ "-default-frame-rate=30",
+ "-default-size=980,590",
+ "-source-path="+nconf.get('sourcePath'),
+ process.cwd()+"/"+file+".as",
+ "-o="+output ]
+
+ execFile(mxmlc,args,function(err,stdout,stderr){
+ if(err){console.log(err);}
+ console.log('Done!'.green);
+ process.exit(0);
+ })
+};
+
+//console.log(process.env);
+if( ! nconf.get('sourceFile') ) {
+ console.log('Run "init" first!'.red);
+ process.exit(0);
+}
+
+//console.log("name: ",program.name);
+//console.log(program.args[0]);
+
+if( ! program.args[0] ) {
+ console.log('build');
+ build( nconf.get('sourceFile') );
+}
+
+//console.log('program.command', program );
+//if(!src_file){
+// build(nconf.get('source-path'));
+//}
+

0 comments on commit 0c1fc68

Please sign in to comment.