google / closure-compiler-npm

Package for managing and documenting closure-compiler for use via npm
Apache License 2.0
333 stars 66 forks source link

bug(paths): build failed if “.js” in the end of the directory name #259

Open Kristinita opened 2 years ago

Kristinita commented 2 years ago

1. Summary

If the directory name ends in .js, Grunt version of google-closure-compiler treats a directory as a file.

Files: js/Clipboard.js -> js/Clipboard.min.js
Files: js/Clipboard.js/KiraSimple.js -> js/Clipboard.js/KiraSimple.min.js

Fatal error: EISDIR: illegal operation on a directory, read

2. MCVE

See this configuration on the KiraGoogleClosureCompilerJSInPath branch of my GitHub repository for debugging and demonstrations.

  1. Gruntfile.coffee:

    module.exports = (grunt) ->
    
        require('google-closure-compiler').grunt grunt
    
        grunt.initConfig
    
            'closure-compiler':
                target:
                    files: [
                        expand: true
                        cwd: "js/"
                        src: ['**/*.js']
                        dest: "js/"
                        ext: '.min.js'
                        ]
    
  2. js/Clipboard.js/KiraSimple.js:

    alert('Kira Goddess!');
    
  3. The part of the package.json:

    {
      "devDependencies": {
        "google-closure-compiler": "^20220905.0.0",
        "grunt": "^1.5.3"
      }
    }
    
  4. The part of the .travis.yml:

    install:
    - npm install -g google-closure-compiler grunt-cli
    - npm install
    
    script:
    - google-closure-compiler --js="js/**.js"
    - grunt closure-compiler --verbose --stack
    

3. Behavior

3.1. Desired

Successful compilation without errors. I get it if:

  1. I use directory name without characters “.js” at the end instead of directory “Clipboard.js”.
  2. For google-closure-compiler CLI I can’t reproduce the bug, see Travis build:

    $ google-closure-compiler --js="js/**.js"
    
    alert("Kira Goddess!");
    
    The command "google-closure-compiler --js="js/**.js"" exited with 0.

3.2. Current

See Travis build:

Initializing

Command-line options: --verbose, --stack, --gruntfile=/home/travis/build/Kristinita/SashaGruntDebugging/Gruntfile.coffee

Reading "Gruntfile.coffee" Gruntfile…OK

Registering Gruntfile tasks.

Initializing config…OK

Loading "Gruntfile.coffee" tasks…OK

+ closure-compiler

Running tasks: closure-compiler

Running "closure-compiler" task

Running "closure-compiler:target" (closure-compiler) task

Verifying property closure-compiler.target exists in config…OK

Files: js/Clipboard.js -> js/Clipboard.min.js

Files: js/Clipboard.js/KiraSimple.js -> js/Clipboard.js/KiraSimple.min.js

Options: args=undefined

Options: args=undefined

Fatal error: EISDIR: illegal operation on a directory, read

Error: EISDIR: illegal operation on a directory, read

The command "grunt closure-compiler --verbose --stack" exited with 3.

4. Environment

  1. Operating system

    1. Local — Microsoft Windows [Version 10.0.19041.1415]
    2. Travis CI — Ubuntu 22.04 LTS Jammy Jellyfish
  2. grunt-cli v1.3.2, grunt v1.5.3

  3. google-closure-compiler v20220905

Thanks.

blickly commented 2 years ago

I haven't investigated, but it's not hard to imagine this assumption creeping in somewhere.

@ChadKillingsworth, do you have a comment/opinion here?

ChadKillingsworth commented 2 years ago

It seems likely that this is within the grunt plugin in some way. It will take some research to figure out exactly what is causing the issue.