Skip to content

Commit

Permalink
Merge pull request #30 from INCATools/issue-29
Browse files Browse the repository at this point in the history
  • Loading branch information
cmungall authored Apr 1, 2023
2 parents 63ac6a5 + 8691627 commit 5496a64
Show file tree
Hide file tree
Showing 6 changed files with 564 additions and 123 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [14.x, 16.x, 18.x]

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ examples/*.dot
*.log
dist/
docs/
.vscode
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## Requirements

* Node.js ≥ 12.20
* Node.js ≥ 14.16

## Installation

Expand Down
31 changes: 15 additions & 16 deletions bin/og2dot.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import { readFileSync, existsSync, writeFileSync } from 'fs';
import { Command } from 'commander';
import { OboGraphViz } from '../dist/index.js';
import { execSync } from 'child_process'
import tmp from 'tmp';
import open from 'open';

// remove all controlled temporary objects on process exit
tmp.setGracefulCleanup();

function multiple(value, previous) {
return previous.concat([value]);
Expand Down Expand Up @@ -39,19 +44,17 @@ if (options['stylemap']) {
styleMap = Object.assign({}, styleMap, JSON.parse(options['stylemap']));
}

var useDatabaseID = options['database-id']

var compoundRelations = options['compoundRelations'] || []
if (options['compoundRelationsInverse']) {
for (let x of options['compoundRelationsInverse']) {
compoundRelations.push({inverseOf:x})
}
}

var text = ""
program.args.forEach (function (filename) {
if (!existsSync (filename))
if (!existsSync (filename)) {
inputError ("File does not exist: " + filename)
}
var data = readFileSync (filename)
//var og = require(filename);
var og = JSON.parse(data)
Expand All @@ -62,21 +65,17 @@ program.args.forEach (function (filename) {
var outfile = options['outfile']
var outfmt = options['to']
if (outfmt && outfmt == 'png') {
var fn = '/tmp/foo.dot'
writeFileSync(fn, dot)
const pngfile = outfile
let dotFile = tmp.fileSync({ postfix: '.dot' }).name;
writeFileSync(dotFile, dot)
var pngfile = outfile
if (!pngfile) {
pngfile = '/tmp/foo.png'
pngfile = tmp.fileSync({ postfix: '.png', keep: true }).name;
}
var cmd = 'dot '+fn+' -Grankdir=BT -Tpng -o ' + pngfile
var cmd = `dot ${dotFile} -Grankdir=BT -Tpng -o ${pngfile}`;
execSync(cmd);
if (outfile) {
//console.log("File is here: "+outfile)
// do nothing - already output
}
else {
console.log("Opening "+pngfile);
execSync('open '+pngfile);
if (!outfile) {
console.log("Opening " + pngfile);
open(pngfile);
}
}
else {
Expand Down
Loading

0 comments on commit 5496a64

Please sign in to comment.