no special chars or camel case in npx command
Closed this issue ยท 9 comments
Would this be referring to the scripts in package.json?
Hi @opethrocks ! Thanks for reaching out. This is refereeing to the npx command used to create the project.
https://github.com/hi-matbub/lg-coffee/blob/main/packages/lg-init/index.js
We need a function to check for "no special chars or camel case" in the name
argument before we actually name and move the directory. I would think a good place for it would be here:
https://github.com/hi-matbub/lg-coffee/blob/da8ea64b9aaa4ea2fcdde5bb9ded07566105bc22/packages/lg-init/index.js#L59-L71
This is basically to reduce the chance of user install errors. It's all you if you want it! ๐ฏ
Awesome! Thanks for the detailed description
Man I have tried just about everything I can think of, throw new Error
, a simple conditional, and a function returning false when a match is found to stop execution of the moveTemplateToUserCurrentWorkingDirectory
function still executes.
hm.. what if we add a function returning false
when a match is found with a conditional?
maybe check for formatting issues right before we send name
into the try/catch block..? ๐ค
const handleNameFormatting = (name) => {
// if name is properly formatted return true
// else false
}
const moveTemplateToUserCurrentWorkingDirectory = (name) => {
// if handleNameFormatting returned false
if( !handleNameFormatting(name) ) {
console.log(`${name} format is not supported`)
return;
} else {
// continue running the command
try {
...
} catch {
...
}
}
}
It's still not working as I would expect. I'm testing by running npx lg-init asdf!@#$
for example and it still continues to make the directory and bootstrap the project.
Hi @opethrocks, that is the published command, you won't be able to see local changes. Try running npx lg-coffee/packages/lg-init/index.js asdf!@#$
to test the command on your local machine, however be mindful of issue #82 !
Ahhh that makes sense! Thanks! I'll try that
Hi @opethrocks quick update if that command isnt working, I guess it needs to be the full path to the file. e.g. npx /Users/admin/Desktop/lg-coffee/packages/lg-init/index.js