const fs = require('fs'); const path = require('path'); const chalk = require(__dirname + '/../../MistyCore/node_modules/chalk'); module.exports = (arguments) => { if (arguments._finals.length > 0) { let newDirectory = path.resolve(arguments._finals[0]); if (fs.existsSync(newDirectory)) { try { fs.accessSync(newDirectory, fs.constants.R_OK); if (!fs.lstatSync(newDirectory).isDirectory()) { console.log(chalk.bgYellow.white("") + " " + chalk.yellow("Not a directory: ") + arguments['_finals'][0]); } else { process.chdir(newDirectory); } } catch (e) { console.log(chalk.bgYellow.white("") + " " + chalk.yellow("Permission denied: ") + arguments['_finals'][0]); } } else { console.log(chalk.bgYellow.white("") + " " + chalk.yellow("No such file or directory: ") + arguments['_finals'][0]); } } else { console.log(chalk.bgYellow.white("") + " " + chalk.yellow("Missing operand")); } }