FortAwesome / angular-fontawesome

Official Angular component for Font Awesome 5+
https://fontawesome.com
MIT License
1.49k stars 152 forks source link

ng-add fails if it can't find tslint #269

Closed madebyjeffrey closed 4 years ago

madebyjeffrey commented 4 years ago

Describe the problem

When performaing ng add @fortawesome/angular-fontawesome@0.6.0 it asked for what font icons I would like:

Installing packages for tooling via npm.
Installed packages for tooling via npm.
? Choose Font Awesome icon packages you would like to use: Free Solid Icons, Free Regular Icons, Free Brands Icons
UPDATE package.json (3013 bytes)
UPDATE src/app/app.module.ts (11139 bytes)

But afterwards failed with: Cannot find module 'tslint'

What did you expect?

It to succeed without any errors. I do not use tslint.

Reproducible test case

Unable to produce a test case on stackblitz, requires command line.

devoto13 commented 4 years ago

Sounds reasonable to me. Feel like submitting a PR?

The fix is to wrap this line into "tslint is installed" check.

madebyjeffrey commented 4 years ago

I am certainly willing to do this. Is there an official method of checking for tslint is installed? Most direct way I can think of is just seeing if node_modules.bin\tslint(.exe)? exists or checking the package_lock or the yarn equivalent.

devoto13 commented 4 years ago

It may be a bit tricky to perform the direct check for all platforms and different package managers. I would suggest to attempt loading the module and see if it fails. Something like below:

try {
  require('tslint');
  return true;
} catch (err) {
  return false;
}
madebyjeffrey commented 4 years ago

That would be beautiful if it works!

madebyjeffrey commented 4 years ago

There might be a testing opportunity as well, but not sure if it is worth it to research it.

devoto13 commented 4 years ago

I don't think there is an easy way to test it, so it is fine without test.