diff --git a/.gitignore b/.gitignore index 7758836..def4ca2 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,5 @@ dssWriter.jar *.LOC *.BIN *.dsc -dssExportJson +dssExportJson* tempPrm.txt diff --git a/nodejs/prm/cmds/update.js b/nodejs/prm/cmds/update.js index d256419..3d753a4 100644 --- a/nodejs/prm/cmds/update.js +++ b/nodejs/prm/cmds/update.js @@ -4,28 +4,47 @@ var path = require('path'); var rimraf = require('rimraf'); var fs = require('fs'); var runtime = require('../lib/runtime'); +var dirPreFix = 'dssExportJson'; module.exports = function(args, callback) { console.log('Running **Update** command.\n'); + var t = new Date().getTime(); var params = { export : true, path : path.join(args.output || process.cwd(), args.prefix+'.dss'), - exportRoot : path.join(args.output || process.cwd()) + exportRoot : path.join(args.output || process.cwd(), dirPreFix+'_'+args.prefix), + regex : args.regex || '.*FLOW_LOC.*' }; - var dir = path.join(params.exportRoot, 'dssExportJson'); + if( args.cache && !args['clean-cache'] && fs.existsSync(params.exportRoot) ) { + // process(args); + console.log('Finished update: '+(new Date().getTime() - t)+'ms'); + callback(); + return; + } + + cleanTmpDir(params.exportRoot, args['clean-cache'], function() { + // kill this file + var dsc = path.join(args.output || process.cwd(), args.prefix+'.dsc'); + if( fs.existsSync(dsc) ) { + fs.unlinkSync(dsc); + } - cleanTmpDir(dir, function(){ runtime(args.runtime, params, args, function(){ - console.log('Finished update'); - callback(); + // process(args); + + console.log('Finished update: '+(new Date().getTime() - t)+'ms'); + cleanTmpDir(params.exportRoot, args.cache, function(){ + callback(); + }); + }); }); }; -function cleanTmpDir(dir, callback) { - if( fs.existsSync(dir) ) { +function cleanTmpDir(dir, clearCache, callback) { + if( fs.existsSync(dir) && clearCache ) { console.log('cleaning dir: '+dir); rimraf(dir, callback); } else {