Skip to content

Commit 78aa5cd

Browse files
committed
TritonDataCenter#46 --dry-run does unnecessary work
1 parent 81e35e2 commit 78aa5cd

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

bin/statemap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,9 @@ var main = function ()
795795
config.tags = [];
796796
}
797797

798+
if (opts.dry_run)
799+
config.dryrun = 1;
800+
798801
file = opts._args[0];
799802

800803
stream = mod_fs.createReadStream(file).pipe(mod_concatjson.parse());
@@ -810,6 +813,9 @@ var main = function ()
810813
obj.data = [];
811814

812815
config.coalesced = mod_statemap.ingest(file, function (datum) {
816+
if (opts.dry_run)
817+
return;
818+
813819
if (!datum.hasOwnProperty('entity')) {
814820
addTag(config, datum);
815821
return;

src/glue.cc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ loadConfig(Isolate *isolate, statemap_config_t *config, Local<Object> obj)
141141
LOADCONFIG_INTFIELD(begin);
142142
LOADCONFIG_INTFIELD(end);
143143
LOADCONFIG_INTFIELD(notags);
144+
LOADCONFIG_INTFIELD(dryrun);
144145

145146
return (0);
146147
}
@@ -202,12 +203,14 @@ ingest(const FunctionCallbackInfo<Value>& args)
202203
return;
203204
}
204205

205-
ingestEmitTags(args, statemap);
206+
if (!config.smc_dryrun) {
207+
ingestEmitTags(args, statemap);
206208

207-
for (entity = statemap->sm_entities; entity != NULL;
208-
entity = entity->sme_next) {
209-
if (ingestEmitEntity(args, statemap, entity) != 0)
210-
break;
209+
for (entity = statemap->sm_entities; entity != NULL;
210+
entity = entity->sme_next) {
211+
if (ingestEmitEntity(args, statemap, entity) != 0)
212+
break;
213+
}
211214
}
212215

213216
args.GetReturnValue().Set(v8::Number::New(isolate,

0 commit comments

Comments
 (0)