MCPcopy Create free account
hub / github.com/Snapchat/Valdi / getModuleName

Function getModuleName

npm_modules/cli/src/commands/newModule.ts:154–183  ·  view source on GitHub ↗
(argv: ArgumentsResolver<CommandParameters>)

Source from the content-addressed store, hash-verified

152}
153
154async function getModuleName(argv: ArgumentsResolver<CommandParameters>): Promise<string> {
155 return argv.getArgumentOrResolve('moduleName', async () => {
156 const result = await inquirer.prompt<{ moduleName?: string }>(
157 [
158 {
159 type: 'input',
160 name: 'moduleName',
161 message: 'Please provide a name for this module:',
162 validate: (input: string) => {
163 const validationError = validateProjectName(input);
164 if (validationError) {
165 return validationError;
166 }
167
168 const sanitized = sanitizeProjectName(input);
169 const destPath = path.join(process.cwd(), sanitized);
170 if (fileExists(destPath)) {
171 return `Path ${destPath} already exists. Choose a different name or delete the folder and try again.`;
172 }
173
174 return true;
175 },
176 },
177 ],
178 {},
179 );
180
181 return sanitizeProjectName(result.moduleName ?? '');
182 });
183}
184
185async function finalConfirmation(destPath: string, argv: ArgumentsResolver<CommandParameters>): Promise<boolean> {
186 return argv.getArgumentOrResolve('skipChecks', async () => {

Callers 4

valdiNewModuleFunction · 0.70
onScrollMethod · 0.50

Calls 6

validateProjectNameFunction · 0.90
sanitizeProjectNameFunction · 0.90
fileExistsFunction · 0.90
getArgumentOrResolveMethod · 0.80
cwdMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected