File tree 3 files changed +42
-3
lines changed
3 files changed +42
-3
lines changed Original file line number Diff line number Diff line change 1
1
var gulp = require ( 'gulp' )
2
2
var babel = require ( 'gulp-babel' )
3
+ var es = require ( 'event-stream' )
3
4
4
5
gulp . task ( 'babel' , function ( ) {
5
- return gulp . src ( 'index.js' )
6
+ return es . concat (
7
+ gulp . src ( 'index.js' )
6
8
. pipe ( babel ( ) )
7
- . pipe ( gulp . dest ( 'lib' ) )
9
+ . pipe ( gulp . dest ( 'lib' ) ) ,
10
+ gulp . src ( 'index_back.js' )
11
+ . pipe ( babel ( ) )
12
+ . pipe ( gulp . dest ( 'lib' ) ) )
8
13
} )
9
14
10
15
gulp . task ( 'default' , [ 'babel' ] )
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env node
2
+ /* global __dirname, process */
3
+
4
+ import program from 'commander'
5
+ import fs from 'fs'
6
+ import getStdin from 'get-stdin'
7
+ import graphlib from 'graphlib'
8
+ import gdot from 'graphlib-dot'
9
+
10
+ program
11
+ . version ( JSON . parse ( fs . readFileSync ( __dirname + '/../package.json' ) ) [ 'version' ] )
12
+ . option ( '-f, --graphfile <graphfile>' , 'Set graph file to parse. If none is given stdin is read' )
13
+ . parse ( process . argv )
14
+
15
+ var processGraph = str => {
16
+ var graph = gdot . read ( str )
17
+ var json = graphlib . json . write ( graph )
18
+ return json
19
+ }
20
+
21
+ if ( program . graphfile ) {
22
+ var str = fs . readFileSync ( program . graphfile )
23
+ console . log ( processGraph ( str ) )
24
+ } else {
25
+ getStdin ( ) . then ( str => {
26
+ try {
27
+ console . log ( processGraph ( str ) )
28
+ } catch ( e ) {
29
+ console . error ( 'Error while processing: ' , e )
30
+ }
31
+ } )
32
+ }
Original file line number Diff line number Diff line change 3
3
"version" : " 1.0.3" ,
4
4
"description" : " Simple command line tool that converts graphlib graphs to dot files via graphlib-dot" ,
5
5
"bin" : {
6
- "graphlib2dot" : " lib/index.js"
6
+ "graphlib2dot" : " lib/index.js" ,
7
+ "dot2graphlib" : " lib/index_back.js"
7
8
},
8
9
"scripts" : {
9
10
"test" : " node node_modules/standard/bin/cmd.js"
30
31
"devDependencies" : {
31
32
"babel" : " ^5.8.29" ,
32
33
"babel-eslint" : " ^4.1.3" ,
34
+ "event-stream" : " ^3.3.2" ,
33
35
"gulp" : " ^3.9.0" ,
34
36
"gulp-babel" : " ^5.3.0" ,
35
37
"standard" : " ^5.4.1"
You can’t perform that action at this time.
0 commit comments