Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
try/catch with glob
node v8.17.0
version:
1.0.0
endpoint
share
tweet
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