Skip to content

Commit

Permalink
start of update cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmerz committed Jan 28, 2016
1 parent 67f4158 commit 2b52ad0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ dssWriter.jar
*.LOC
*.BIN
*.dsc
dssExportJson
dssExportJson*
tempPrm.txt
33 changes: 26 additions & 7 deletions nodejs/prm/cmds/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2b52ad0

Please sign in to comment.