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

using tslint cli as npm script has inconsistent path behavior for windows and linux #1639

Closed
acdcjunior opened this issue Oct 18, 2016 · 2 comments

Comments

@acdcjunior
Copy link

acdcjunior commented Oct 18, 2016

Bug Report

  • TSLint version: ~3.15.1
  • TypeScript version: ~2.0.3
  • Running TSLint via: CLI via NPM script

TypeScript code being linted: (irrelevant)
with tslint.json configuration: (irrelevant)

package.json configuration:

  "scripts": {
    "unquoted": "tslint src/**/*.ts",
     "quoted": "tslint 'src/**/*.ts'"
  },

Actual behavior

Unconsistend behavior when running @ windows or linux (and not working at all on windows).

Expected behavior

Consistent behavior across platforms.

Workaround

Use both, I guess:

  "scripts": {
    "unquoted_and_quoted": "tslint src/**/*.ts && tslint 'src/**/*.ts'"
  },

How to reproduce:

Check readme and files: https://github.com/acdcjunior/tslint-windows-path-inconsistency
(pasting README here for reference:)

Unquoted path (npm run unquoted)

  • @windows 10

    • All good: three linting errors!
    $ npm run unquoted
    
    > tslint-windows-path-inconsistency@1.0.0 unquoted D:\github\tslint-windows-path-inconsistency
    > tslint src/**/*.ts
    
    src/FirstLevel.ts[1, 12]: " should be '
    src/second/SecondLevel.ts[1, 12]: " should be '
    src/second/third/ThirdLevel.ts[1, 12]: " should be '
    
    npm ERR! Windows_NT 10.0.14393
    ...
  • @CentOS 7

    • Only one error when three are expected!
    [box@box tslint-windows-path-inconsistency]$ npm run unquoted
    
    > tslint-windows-path-inconsistency@1.0.0 unquoted /box/github/tslint-windows-path-inconsistency
    > tslint src/**/*.ts
    
    src/second/SecondLevel.ts[1, 12]: " should be '
    
    npm ERR! Linux 3.10.0-229.el7.x86_64
    ...

Quoted path (npm run quoted)

  • @windows 10

    • Bad: no error whatsoever!
    $ npm run quoted
    
    > tslint-windows-path-inconsistency@1.0.0 quoted D:\github\tslint-windows-path-inconsistency
    > tslint 'src/**/*.ts'
    
    $
  • @CentOS 7

    • All good!
    [box@box tslint-windows-path-inconsistency]$ npm run quoted
    
    > tslint-windows-path-inconsistency@1.0.0 quoted /box/github/tslint-windows-path-inconsistency
    > tslint 'src/**/*.ts'
    
    src/FirstLevel.ts[1, 12]: " should be '
    src/second/SecondLevel.ts[1, 12]: " should be '
    src/second/third/ThirdLevel.ts[1, 12]: " should be '
    
    npm ERR! Linux 3.10.0-229.el7.x86_64
    ...
@acdcjunior acdcjunior changed the title using tslint as npm script has inconsistent path behavior for windows and linux using tslint cli as npm script has inconsistent path behavior for windows and linux Oct 18, 2016
@IllusionMH
Copy link
Contributor

IllusionMH commented Nov 3, 2016

@acdcjunior you can use double quotes " (escaped) as workaround to ensure consistency between platforms.

"scripts": {
  "lint": "tslint \"src/**/*.ts\""
},

I have idea how to fix it, but need more time to ensure that fix for running TSLint from npm scripts won't break anything when it is used directly from terminal.

@jkillian
Copy link
Contributor

jkillian commented Nov 3, 2016

Hi @acdcjunior, this answer and this comment should provide context for the different behavior you're seeing.

When running in centos unquoted, perhaps you don't have the globstar option enabled in your shell and thus the glob isn't matching the files you expect. @IllusionMH's recommendation is good, use double-quotes so that node-glob processes the glob.

I actually don't think this is a bug, it's just how shells work, so I'm going to close this. If you have an idea to change stuff for the better @IllusionMH, happy to reopen / accept that change.

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