Tengo una función checkIsDir y la he importado al archivo principal cli.js pero no puedo acceder al valor que se devuelve, en este caso, es true .
checkIsDir.js
const fs = require('fs') const listr = require('listr') function checkIsDir(path) { const tasks = new listr([ { title: 'Checking if path is a directory', task: () => { try { fs.lstatSync(path).isDirectory() // return true if the path is a directory return true } catch (err) { throw new Error(`Path ${path} is not a directory`) } } } ]) tasks.run().catch(err => { throw new Error(err) }) } module.exports = checkIsDir cli.js
#! /usr/bin/env node const inquirer = require('inquirer'); const fs = require('fs') const questions = require('./data/questions'); const checkIsDir = require('./lib/checkIsDir'); const spiltPath = require('./lib/splitPath'); const path = process.cwd(); inquirer.prompt(questions).then(async (answers) => { console.log(checkIsDir(answers.path)) if (checkIsDir(answers.path) === true) { spiltPath(answers.path); } else { console.log('Oh no') } }); splitPath.js
function spiltPath(path) { var spiltArray = path.split('/'); var folderName = spiltArray[spiltArray.length - 1]; console.log(folderName); } module.exports = spiltPath