Commits

kai zhu committed dd1452c

fix lineno. use module.filename instead of module.id.

Comments (0)

Files changed (3)

 
 /*
 CHANGELOG
-merge cli.js, libStable.js2, libUnstable.js into moduleMain.js. migrate from nopt to commander.
+fix lineno.  use module.filename instead of module.id.
 
 TODO
 add client-side interactive tests.
         .option('--debug', 'debug mode')
         .option('--port []', 'http port', parseInt)
         .parse(process.argv);
-      console.log(EXPORTS.requireCommander);
       EXPORTS.COVER = EXPORTS.COVER || new EXPORTS.requireIstanbul.Instrumenter();
       EXPORTS.COVER_FILE = EXPORTS.COVER_FILE || {};
       EXPORTS.FS_CWD = EXPORTS.FS_CWD || process.cwd();
         try { val = JSON.parse(val); } catch (errParse) {}
         EXPORTS['IS_' + key.replace((/\W/g), '_').toUpperCase()] = val;
         switch (key) {
+        // case 'cover':
+          // if (!EXPORTS.COVER_FILE.hasOwnProperty(module.filename)) {
+            // EXPORTS.moduleLoad(module);
+          // }
+          // return;
         case 'debug':
           //// display environment
           console.log(['process.argv', process.EXPORTS.ARGV]);
           console.log(['cwd', EXPORTS.FS_CWD]);
           console.log(['nodejs', process.version]);
-          console.log(['module', module.filename, module.id]);
+          console.log(['module', module.id, module.filename]);
           break;
         case 'port':
           EXPORTS.HTTP_PORT = val;
 
     moduleCover: function (module, file, code) {
       if (EXPORTS.IS_COVER) {
-        EXPORTS.MODULE_FILE[file.name] = EXPORTS.coverInstrument(code, module.id + '.' + file.name);
+        EXPORTS.MODULE_FILE[file.name] = EXPORTS.coverInstrument(code, module.filename + '.' + file.name);
       }
     },
 
       if (typeof module === 'string') {
         module = EXPORTS.requirePath.resolve(EXPORTS.FS_CWD, module);
         module = EXPORTS.MODULES[module] || new EXPORTS.requireModule.Module(module);
+        module.filename = module.filename || module.id;
       }
-      EXPORTS.MODULES[module.id] = module;
+      EXPORTS.MODULES[module.filename] = module;
       //// bump up version
       EXPORTS.VERSION = new Date().toISOString().replace((/(....)-(..)-(..)T(..):(..):(..).*/), '$1.$2.$3-$4.$5.$6');
       return content.replace((/^\/\*FILE_BEG (.*?)\*\/$([\S\s]*?)^\/\*FILE_END\*\/$/gm), function (_, file, code, start) {
         //// filename
         file.name = file.name.replace((/\/FS_MODULE\b/), EXPORTS.FS_MODULE);
         //// preserve line number position
-        code = (content.slice(0, start).match('\n') || []).join('') + code;
+        code = (content.slice(0, start).match(/\n/g) || []).join('') + code;
         //// save source code
         EXPORTS.MODULE_FILE[file.name] = EXPORTS.stringFormat ? EXPORTS.stringFormat(code, { EXPORTS: EXPORTS }) : code;
         file.actions.forEach(function (action) {
         return;
       case 'grep':
         EXPORTS.shell(
-          'grep -in ' + JSON.stringify(bb) + ' $(find . -type f | grep -v "/\\.\\|\\b\\(\\.\\d\\|build\\|docs\\|min\\|node_modules\\|rollup\\|swp\\|test\\|tmp\\)\\b")'
+          'grep -in ' + JSON.stringify(bb) + ' $(find . -type f | grep -v "/\\.\\|\\b\\(\\.\\d\\|build\\|coverage\\|docs\\|min\\|node_modules\\|rollup\\|swp\\|test\\|tmp\\)\\b")'
         );
         return;
       //// print function
 /*FILE_BEG {"actions": ["jslint", "write"], "name": "/FS_MODULE/yuidoc.json"}*/
 {
   "options": {
-    "port": "4060",
-    "extension": ".js,.js2",
     "outdir": "./docs"
   }
 }
   "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1"
   },
-  "version": "2013.03.17-18.26.14"
+  "version": "2013.03.17-19.36.40"
 }