Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ampersand gen does not throw a proper error when specifying an invalid type #123

Open
coder13 opened this issue Dec 15, 2016 · 0 comments
Open

Comments

@coder13
Copy link

coder13 commented Dec 15, 2016

This is the result of another error I found when I was trying to do ampersand gen collection and it was complaining

path.js:7
    throw new TypeError('Path must be a string. Received ' + inspect(path));
    ^

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at Object.relative (path.js:1229:5)
    at module.exports (/home/caleb/.nvm/versions/node/v6.7.0/lib/node_modules/ampersand/lib/generate-template.js:54:31)
    at Object.<anonymous> (/home/caleb/.nvm/versions/node/v6.7.0/lib/node_modules/ampersand/bin/ampersand:59:5)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.runMain (module.js:590:10)

if (type === 'router') {
folderPath = path.join(config.approot, config.clientfolder);
filePath = path.join(folderPath, (fileName || 'router.js'));
} else if (type === 'model') {
if (!name) quit('please specify a name: ampersand gen model ' + chalk.magenta('${your model name}'));
folderPath = path.join(config.approot, config.clientfolder, config.modelfolder);
collectionPath = path.join(config.approot, config.clientfolder, config.collectionfolder);
filePath = path.join(folderPath, fileName);
collectionToModelPath = path.join(path.relative(collectionPath, folderPath), name).replace(/\\/g, '/');
} else if (type === 'view') {
if (!name) quit('please specify a name: ampersand gen view ' + chalk.magenta('${your view name}'));
folderPath = path.join(config.approot, config.clientfolder, config.viewfolder);
filePath = path.join(folderPath, fileName);
} else if (type === 'page') {
if (!name) quit('please specify a name: ampersand gen page ' + chalk.magenta('${your page name}'));
folderPath = path.join(config.approot, config.clientfolder, config.pagefolder);
filePath = path.join(folderPath, fileName);
} else if (type === 'form') {
if (!name) quit('please specify a path to the model: ampersand gen form ' + chalk.magenta('${path to model}'));
folderPath = path.join(config.approot, config.clientfolder, config.formsfolder);
filePath = path.join(folderPath, path.basename(fileName));
}

does not have an if case for collection even though the doc says that I can ampersand gen collection
thus
config.relPath = path.relative(process.cwd(), filePath);
complains about filePath being undefined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant