Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Running CLI when checked out via a Git dependency does not work #4131

Closed
wilg opened this issue Aug 23, 2018 · 9 comments
Closed

Running CLI when checked out via a Git dependency does not work #4131

wilg opened this issue Aug 23, 2018 · 9 comments

Comments

@wilg
Copy link

wilg commented Aug 23, 2018

Bug Report

  • TSLint version: e766f51
  • TypeScript version:3.0.1
  • Running TSLint via: CLI

With TSLint included via Yarn with "tslint": "https://github.com/palantir/tslint#master" (or pinned to a recent master sha like e766f51), TSLint installs but the CLI does not work.

Using "tslint": "5.11.0", works fine.

Actual behavior

tslint --project tsconfig.json --format stylish 'lib/helltool/assets/**/*.ts' 'test/javascripts/**/*.ts'
module.js:529
    throw err;
    ^

Error: Cannot find module '../lib/tslintCli'
    at Function.Module._resolveFilename (module.js:527:15)
    at Function.Module._load (module.js:476:23)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/wil/Code/looker/helltool/node_modules/tslint/bin/tslint:3:1)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
error Command failed with exit code 1.

No lib folder exists, presumably due to something in the compilation process:

› ls node_modules/tslint
CHANGELOG.md  README.md     bin/   node_modules/  scripts/  test/        yarn.lock
LICENSE       appveyor.yml  docs/  package.json   src/      tslint.json

When installed via a version on NPM (which works):

› ls node_modules/tslint
CHANGELOG.md  LICENSE  README.md  bin/  lib/  node_modules/  package.json

Expected behavior

TSLint's CLI works when installed in this way.

@giladgray
Copy link

giladgray commented Aug 27, 2018

@wilg tslint was never designed to be used that way. the repo does not contain compiled artifacts--only the published NPM package contains those. so of course it doesn't run: there's nothing to run!

this to say: the lib/ directory only exists on NPM (or after compiling the code locally).

@wilg
Copy link
Author

wilg commented Aug 27, 2018

I understand that, but I was under the impression there was some kind of package.json configuration (a postinstall script?) that would allow this to work.

I am trying to use #3641 in my project, but without the ability to use TSLint from Git I don't see how I can use that until a release is created. Is there another way to do this? Does everyone just wait until a release is made to test TSLint against their code?

Alternatively, is there an expected date for the next release?

@giladgray
Copy link

@wilg instead of depending on the git repo, checkout the repo locally and build it. then yarn link (or npm link) to use your local copy.

@wilg
Copy link
Author

wilg commented Aug 27, 2018

Thanks, I will try that for testing. Unfortunately, it still means that I can't easily add the latest TSLint as a project dependency until an official release is made (because no other developers or build systems will be able to run it without a bunch of custom glue).

It also seems like it would make contributing to TSLint a bit harder because I can't fork it to add a feature or fix a bug and then use my enhanced/fixed version until an official release is made, which is a pretty common pattern.

@giladgray
Copy link

yes that is true and by design: you can not depend on the tip of tslint, only on published versions.

@JoshuaKGoldberg
Copy link
Contributor

@giladgray Can we have nightly releases the way TypeScript does? There wouldn't be any guarantee of stability.

@karfau
Copy link

karfau commented Sep 3, 2018

@wilg What I usually d in such cases is to create a fork, and after creating my fix, I branch of from the branch for the PR, and commit the compiled output into that branch only. This way I can put github:user-or-org/repo#hash (or the equivalent https link) as a depenency into package.json

@giladgray
Copy link

@JoshuaKGoldberg i'm in favor of nightlies 👍

@JoshuaKGoldberg
Copy link
Contributor

Per #4534 this seems like not a priority anymore. If anybody actually does need this (please do post here if so!) we can reopen.

You can always run TSLint with ts-node, so in theory there could be some hackery possible to get the raw git equivalent to work... Failing that, you can fork the repo, remove .ts files from .gitignore, and check in built artifacts. 🤷‍♂

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

No branches or pull requests

4 participants