List all js files in the directory
(dir, fileArray)
| 12 | |
| 13 | /** List all js files in the directory */ |
| 14 | function getJsFiles(dir, fileArray) { |
| 15 | const files = fs.readdirSync(dir); |
| 16 | fileArray = fileArray || []; |
| 17 | files.forEach(function(file) { |
| 18 | if (file === 'node_modules') { |
| 19 | return; |
| 20 | } |
| 21 | if (fs.statSync(dir + file).isDirectory()) { |
| 22 | getJsFiles(dir + file + '/', fileArray); |
| 23 | return; |
| 24 | } |
| 25 | if (file.substring(file.length-3, file.length) !== '.js') { |
| 26 | return; |
| 27 | } |
| 28 | fileArray.push(dir+file); |
| 29 | }); |
| 30 | return fileArray; |
| 31 | } |
| 32 | |
| 33 | if (+process.versions.node.split('.')[0] < 10) { |
| 34 | console.log('Examples were not executed as they were designed to run against Node.js 10+'); |