Skip to content

Commit

Permalink
Various cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxattax97 committed Mar 13, 2019
1 parent 6277ac1 commit 54c580b
Show file tree
Hide file tree
Showing 6 changed files with 3,396 additions and 109 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Currently it's opinionated, but there may be improvements in the future which
allow you to alter the code style it enforces.

## Install
The utility is available on [npm](), you can install it like so:
The utility is available on [npm](https://www.npmjs.com/package/openscad-format), you can install it like so:
```
$ npm install -g openscad-format
```
Expand Down Expand Up @@ -40,5 +40,5 @@ platforms.
```

## Contribute
Make sure your PR's pass the unit tests, are free of ESLint errors. To check,
Make sure your PR's pass the unit tests and are free of ESLint errors. To check,
run `npm run all` and it will guide you through what needs to be done.
26 changes: 17 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ const { argv } = require('yargs')
.alias('o', 'output')
.nargs('o', 1)
.describe('o', 'Output file to write')
.alias('f', 'force')
.nargs('f', 1)
.describe('f', 'Forcibly overwrite the source file')
.alias('d', 'dry')
.nargs('d', 1)
.describe('d', 'Perform a dry run, without writing')
.help('h')
.alias('h', 'help')
.epilog('This utility requires clang-format, but this is automatically installed for most platforms.');
Expand Down Expand Up @@ -193,18 +199,20 @@ async function main(input, output) {
argv.output = output;
}

try {
argv.input = await globby(argv.input, {
deep: true,
gitignore: true,
});
} catch (err) {
console.error(`Failed to glob input using ${argv.input}`, err);
if (argv.input) {
try {
argv.input = await globby(argv.input, {
deep: true,
gitignore: true,
});
} catch (err) {
console.error(`Failed to glob input using ${argv.input}`, err);
}
}

if (argv.input.length > 1) {
if (argv.input && argv.input.length > 1) {
argv.output = null;
} else if (!argv.output && argv.input.length === 1) {
} else if (!argv.output && argv.input && argv.input.length === 1) {
argv.output = argv.input;
}

Expand Down
Loading

0 comments on commit 54c580b

Please sign in to comment.