slushjs / gulp-install

Automatically install npm and bower packages if package.json or bower.json is found in the gulp file stream respectively
MIT License
106 stars 46 forks source link

Wildcard globs not working properly in gulp #48

Closed isochronous closed 7 years ago

isochronous commented 7 years ago

This is with: Gulp 3.9.1 Node 4.7.3 Gulp-install 0.6.0 Windows 10

We have a directory structure like this:

+ui
    +src
        +elements
            +bower_components
            +ai-common-elements
                +ai-auth
                +ai-menu
                .bowerrc
                bower.json
            +ai-shell
                .bowerrc
                bower.json

Where each entry prefixed with + is a folder. Every .bowerrc file specifies the install directory for bower to be the ui/src/elements/bower_components folder, so we can maintain consistent relative paths between all folders.

The problem is that using the ** wildcard in src globs doesn't work:

// immediately finishes, does nothing
return gulp.src('./ui/src/elements/**')
    .pipe(install());

// also immediately finishes, doing nothing
return gulp.src('./ui/src/elements/**/bower.json')
    .pipe(install());

// this works, but I'd rather not have to continually update this glob array every time we create
// a new element
return gulp.src([
        './ui/src/elements/ai-common-elements/bower.json',
        './ui/src/elements/ai-shell/bower.json'
    ])
    .pipe(install());
isochronous commented 7 years ago

I'm not sure why this helped, but I found that this glob array (mostly) works:

var workingBowerGlobs = [
    'ui/src/elements/**/bower.json',
    '!ui/src/elements/bower_components/**/bower.json'
];

Unfortunately, I'm still getting a bunch of EPERM errors thrown by bower that don't happen if I just run bower install normally from a terminal. This may not be your issue, but it's weird that they only happen when running bower install through this plugin.

Sample of the errors (apologies for the horrible formatting, but that's how it looks in the terminal, too).

Error: EPERM: operation not permitted, rename 'C:\Users\SomeUser\.config\configstore\bower-github.json.604294665' -> 'C:\Users\SomeUser\.config\configstore\bower-github.js
                        ^

Error: EPERM: operation not permitted, rename 'C:\Users\SomeUser\.config\configstore\bower-github.json.2655415739' -> 'C:\Users\SomeUser\.config\configstore\bower-github.jon'
Eson'
    at Error (native)
EPERM    at Error (native)
    at Object.fs.renameSync (fs.js:681:18)
PERM    at Object.fs.renameSync (fs.js:681:18)
    at Function.writeFileSync [as sync] (C:\Program Files (x86)\Nodist\bin\node_modules\bower\lib\node_modules\write-file-atomic\index.js:81:8)
 EPERM: operation not permitted, rename 'C:\Users\SomeUser\.config\configstore\bower-github.json.4222190069' -> 'C:\Users\SomeUser\.config\configstore\bower-github.jso
at Function.writeFileSync [as sync] (C:\Program Files (x86)\Nodist\bin\node_modules\bower\lib\node_modules\write-file-atomic\index.js:81:8)
    at Object.create.all.set (C:\Program Files (x86)\Nodist\bin\node_modules\bower\lib\node_modules\configstore\index.js:63:21)
n'
    at Object.create.all.set (C:\Program Files (x86)\Nodist\bin\node_modules\bower\lib\node_modules\configstore\index.js:63:21)
 EPE    at Object.Configstore (C:\Program Files (x86)\Nodist\bin\node_modules\bower\lib\node_modules\configstore\index.js:28:11)
    at Object.Configstore (C:\Program Files (x86)\Nodist\bin\node_modules\bower\lib\node_modules\configstore\index.js:28:11)
RM: operation not permitted, rename 'C:\Users\SomeUser\.config\configstore\bower-github.json.1190275566' -> 'C:\Users\SomeUser\.config\configstore\bower-github.json'
    at readCachedConfig (C:\Program Files (x86)\Nodist\bin\node_modules\bower\lib\config.js:19:23)
    at readCachedConfig (C:\Program Files (x86)\Nodist\bin\node_modules\bower\lib\config.js:19:23)
    at defaultConfig (C:\Program Files (x86)\Nodist\bin\node_modules\bower\lib\config.js:11:12)
    at defaultConfig (C:\Program Files (x86)\Nodist\bin\node_modules\bower\lib\config.js:11:12)
    at Object.<anonymous> (C:\Program Files (x86)\Nodist\bin\node_modules\bower\lib\index.js:16:32)
    at Object.<anonymous> (C:\Program Files (x86)\Nodist\bin\node_modules\bower\lib\index.js:16:32)
    at Module._compile (module.js:409:26)

Stack trace:
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Object.Module._extensions..js (module.js:416:10)
isochronous commented 7 years ago

I'm guessing that this issue is due to multiple calls to bower install running in parallel, which is causing issues with file locking. An option to run them in series would maybe be a good idea. Since this issue is now completely different from the original complaint, I'm closing this thread, and may open another... though it appears this project has been abandoned, so I'll probably just try to roll my own custom solution.

joakimbeng commented 7 years ago

@isochronous v1.0.0 is out now! The new version groups commands so it only runs for instance one npm install and one bower install in parallel, so per command it's run in series which solves your issue above.

isochronous commented 7 years ago

Awesome, great news! Thanks so much :D On Thu, Mar 23, 2017 at 4:18 AM Joakim Carlstein notifications@github.com wrote:

@isochronous https://github.com/isochronous v1.0.0 is out now! The new version groups commands so it only runs for instance one npm install and one bower install in parallel, so per command it's run in series which solves your issue above.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/slushjs/gulp-install/issues/48#issuecomment-288647026, or mute the thread https://github.com/notifications/unsubscribe-auth/AAvR0R4CBpl7skWYr1lizKAQHRAdaFiIks5roirlgaJpZM4MdKGX .

isochronous commented 7 years ago

Finally went back to using this, and though it seems to be working exactly as it should, I can't say the same for the stdout logging, which seems to be stripping line breaks from npm output. It's not a big deal, but it does making reading install logs rather challenging, as one line just runs into the next and line breaks happen wherever the column limit on the terminal is.