File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 22const fs = require ( 'fs' ) ;
33const pathExists = require ( 'path-exists' ) ;
44
5- module . exports = filename => new Promise ( resolve => {
5+ module . exports = filename => new Promise ( ( resolve , reject ) => {
66 if ( pathExists . sync ( filename ) ) {
77 const stats = fs . statSync ( filename ) ;
88 resolve ( stats . size ) ;
99 }
1010
11- throw new Error ( `File "${ filename } " not found` ) ;
11+ reject ( new Error ( `File "${ filename } " not found` ) ) ;
1212} ) ;
1313
1414module . exports . sync = filename => {
Original file line number Diff line number Diff line change @@ -23,9 +23,12 @@ test('small file sync', t => {
2323} ) ;
2424
2525test ( 'invalid args promise' , async t => {
26- t . throws ( ( ) => {
27- fileBytes . sync ( 'invalidFileName.txt' ) ;
28- } , Error ) ;
26+ try {
27+ await fileBytes ( 'invalidFileName.txt' ) ;
28+ t . fail ( 'Exception was not thrown' ) ;
29+ } catch ( err ) {
30+ t . truthy ( err ) ;
31+ }
2932} ) ;
3033
3134test ( 'empty file promise' , async t => {
You can’t perform that action at this time.
0 commit comments