try/catch with glob

node v8.17.0
version: 1.0.0
endpointsharetweet
const path = require('path'); const glob = require('glob');
const callback = (err, result) => { if (err) { console.log(err); } else if (result) { console.log(result); } else { console.log('hmmmm...'); } };
const globPattern = '**/templates'; const ignore = '**/node_modules/**'; const globOptions = { ignore }; try { const { result } = glob.sync(globPattern, globOptions) const templatePath = path.resolve(process.cwd(), result, 'moduleName'); throw new Error('eeee'); callback(null, templatePath); } catch (ex) { callback(ex); }
glob(globPattern, globOptions, (err, [result]) => { if (err) { callback(err); } try { const templatePath = path.resolve(process.cwd(), result, 'moduleName'); throw new Error('eeee'); callback(null, templatePath); } catch (ex) { callback(ex); } });
Loading…

no comments

    sign in to comment