Skip to content

Commit 537222c

Browse files
committed
Meta tweaks
1 parent 2cc9785 commit 537222c

4 files changed

Lines changed: 37 additions & 50 deletions

File tree

.gitattributes

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
* text=auto
2-
*.js text eol=lf
1+
* text=auto eol=lf

index.js

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,13 @@ module.exports = class BinWrapper {
112112
* @api public
113113
*/
114114
run(cmd = ['--version']) {
115-
return this.findExisting()
116-
.then(() => {
117-
if (this.options.skipCheck) {
118-
return;
119-
}
120-
121-
return this.runCheck(cmd);
122-
});
115+
return this.findExisting().then(() => {
116+
if (this.options.skipCheck) {
117+
return;
118+
}
119+
120+
return this.runCheck(cmd);
121+
});
123122
}
124123

125124
/**
@@ -129,18 +128,17 @@ module.exports = class BinWrapper {
129128
* @api private
130129
*/
131130
runCheck(cmd) {
132-
return binCheck(this.path(), cmd)
133-
.then(works => {
134-
if (!works) {
135-
throw new Error(`The \`${this.path()}\` binary doesn't seem to work correctly`);
136-
}
137-
138-
if (this.version()) {
139-
return binVersionCheck(this.path(), this.version());
140-
}
141-
142-
return Promise.resolve();
143-
});
131+
return binCheck(this.path(), cmd).then(works => {
132+
if (!works) {
133+
throw new Error(`The \`${this.path()}\` binary doesn't seem to work correctly`);
134+
}
135+
136+
if (this.version()) {
137+
return binVersionCheck(this.path(), this.version());
138+
}
139+
140+
return Promise.resolve();
141+
});
144142
}
145143

146144
/**
@@ -149,14 +147,13 @@ module.exports = class BinWrapper {
149147
* @api private
150148
*/
151149
findExisting() {
152-
return statAsync(this.path())
153-
.catch(err => {
154-
if (err && err.code === 'ENOENT') {
155-
return this.download();
156-
}
157-
158-
return Promise.reject(err);
159-
});
150+
return statAsync(this.path()).catch(err => {
151+
if (err && err.code === 'ENOENT') {
152+
return this.download();
153+
}
154+
155+
return Promise.reject(err);
156+
});
160157
}
161158

162159
/**

license

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
The MIT License (MIT)
1+
MIT License
22

33
Copyright (c) Kevin Mårtensson <[email protected]>
44

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
116

12-
The above copyright notice and this permission notice shall be included in
13-
all copies or substantial portions of the Software.
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
148

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-
THE SOFTWARE.
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

readme.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ const bin = new BinWrapper()
2424
.use(process.platform === 'win32' ? 'gifsicle.exe' : 'gifsicle')
2525
.version('>=1.71');
2626

27-
bin.run(['--version'])
28-
.then(()) => {
29-
console.log('gifsicle is working');
30-
});
27+
(async () => {
28+
await bin.run(['--version']);
29+
console.log('gifsicle is working');
30+
})();
3131
```
3232

3333
Get the path to your binary with `bin.path()`:
@@ -46,6 +46,8 @@ Creates a new `BinWrapper` instance.
4646

4747
#### options
4848

49+
Type: `Object`
50+
4951
##### skipCheck
5052

5153
Type: `boolean`<br>
@@ -124,6 +126,7 @@ Default: `['--version']`
124126
Command to run the binary with. If it exits with code `0` it means that the
125127
binary is working.
126128

129+
127130
## License
128131

129132
MIT © [Kevin Mårtensson](http://kevinmartensson.com)

0 commit comments

Comments
 (0)