UNPKG

@gkotulski/doc_preprocessing

Version:
38 lines (35 loc) 1.14 kB
#!/usr/bin/env node const preproc = require("./lib/preprocessor") const args = require('yargs').argv; const log = require('./lib/log') const fs = require('fs') function getDirectories(path) { return fs.readdirSync(path).filter(function (file) { return fs.statSync(path+'/'+file).isDirectory(); }); } if(args.path && args.output) { let startPath = args.path var lastChar = startPath[startPath.length - 1] if(lastChar == '*') // TODO replace by glob { startPath = startPath.substring(0, startPath.length - 1) const folders = getDirectories(startPath) folders.forEach(element => { var preprocessor = new preproc.Preprocessing(startPath + '/' + element + '/', args.output + '/' + element + '/') preprocessor.run() }); } else { var preprocessor = new preproc.Preprocessing(args.path, args.output) preprocessor.run() } } else if(args.path && args.force) { var preprocessor = new preproc.Preprocessing(args.path, args.path) preprocessor.run() } else { log.show(log.MESSAGE.ERROR, "Options not recognized") }