jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.26k stars 508 forks source link

Creating a project with a number as name gives confusing error #1054

Open flaviocopes opened 3 years ago

flaviocopes commented 3 years ago

Current Behavior

I was trying various tools and created a folder structure with subfolders named 1, 2, 3, so when I tried tsdx I ran

npx tsdx create 4

and after choosing the basic template I got the error Missing options. Ensure you pass --name flag to tsdx.

Took me a little while to figure out the problem was the number, as running

npx tsdx create test

worked.

Expected behavior

I expect either it to work correctly, or to tell me using a number with npx tsdx create does not work.

Suggested solution(s)

Additional context

Your environment

  System:
    OS: macOS 11.4
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 1.05 GB / 16.00 GB
    Shell: 3.1.0 - /usr/local/bin/fish
  Binaries:
    Node: 16.4.0 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.18.1 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Browsers:
    Chrome: 91.0.4472.114
    Firefox: 89.0
    Safari: 14.1.1
  npmGlobalPackages:
    typescript: 4.3.4
agilgur5 commented 2 years ago

I don't believe 4 is a valid package name. But PR welcome to make the error more friendly.

I didn't write this code (and don't use create), but I believe that's because create runs a regex replace on the input. In this case it replaces it with an empty string, hence the "Missing" error.