New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

diagrams

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diagrams - npm Package Compare versions

Comparing version 0.8.3 to 0.9.0

bin/diagrams-build.js

42

bin/diagrams-watch.js
#!/usr/bin/env node
var program = require('commander'),
build = require('../src/build')
fs = require('fs');
program
.option('b --build', 'build')
.parse(process.argv);
// There should not be more than one directory provided
var buildPlusManyParameters = process.argv.length>=5 && typeof program.build !== 'undefined';
var noBuildTooManyParameters = !buildPlusManyParameters && process.argv.length>=5;
if( buildPlusManyParameters || noBuildTooManyParameters){
if( process.argv.length>=4 ){
reportError('Only one directory argument expected');

@@ -18,4 +16,3 @@ }

var watchDirectory = ".";
if( (program.build && process.argv.length === 5) ||
process.argv.length === 4 ) {
if( process.argv.length === 3 ) {
watchDirectory = process.argv[2];

@@ -35,35 +32,6 @@

var path = require('path');
var chokidar = require('chokidar');
// Chokidar didn't seem to respect a glob pattern properly, so I have implemented
// the filtering on a watch of the entire directory. I filed an issue/question here:
// https://github.com/paulmillr/chokidar/issues/544
chokidar.watch(watchDirectory, {ignoreInitial:!program.build}).on('all', (event, inputPath) => {
if( inputPath.match(/^.*\.(dot|sequence|flowchart|railroad)$/) !== null ){
if( event==='add' || event==='change' ) {
convertFile(inputPath);
}
}
});
function convertFile(inputPath) {
var extension = inputPath.match(/^.*\.(dot|sequence|flowchart|railroad)$/)[1];
var outputPath = inputPath+'.svg';
console.log(inputPath + ' -> ' + outputPath);
// Create dynamic path to matching generator for extension. Example for 'sequence' it ends
// up as: var generator = require('../src/sequence/sequence')
var generator = require('../src/'+extension+'/'+extension);
generator(inputPath, outputPath, function(err){
if(err){
reportError(err);
}
})
}
function reportError(explanation){
console.log("Error: " + explanation);
process.exit(1);
}
build(true, watchDirectory, ()=>{});

@@ -12,3 +12,4 @@ #!/usr/bin/env node

.command('railroad [inputFilePath] [outputFilePath.svg]', 'Generate a railroad diagram in svg')
.command('watch [directory] [--build]', 'Watch a directory for diagram files and automatically generate/update their matching .svg. If --build is provided existing diagram files will first generate their match .svg.')
.command('build [directory]', 'Scans a directory for diagram files and generates their matching .svg')
.command('watch [directory]', 'Watch a directory for diagram files and automatically generate/update their matching .svg')
.parse(process.argv);

@@ -15,0 +16,0 @@

{
"name": "diagrams",
"version": "0.8.3",
"version": "0.9.0",
"description": "Generate Flowcharts, Network Sequence, Dot, and Railroad Diagrams",

@@ -13,7 +13,8 @@ "main": "src/diagrams.js",

"dependencies": {
"chokidar": "^1.6.1",
"commander": "2.8.1",
"electron-prebuilt": "^0.36.2",
"glob": "^7.1.2",
"railroad-diagrams": "1.0.0",
"viz.js": "^1.3.0",
"chokidar": "^1.6.1"
"viz.js": "^1.3.0"
},

@@ -20,0 +21,0 @@ "repository": {

@@ -23,3 +23,3 @@ # Overview

Watches the current directory and generates an .svg file in the same directory as any found file.
Generates all of the .svg files, then starts watching the current directory and regenerates any diagram file that changes.
```

@@ -29,5 +29,5 @@ diagrams watch

Same as above but also first generates all .svg files before starting watch process
Generates all .svg files, but don't start watching after.
```
diagrams watch --build
diagrams build
```

@@ -34,0 +34,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc