armed / gulp-flatten Goto Github PK
View Code? Open in Web Editor NEWGulp plugin: remove or replace relative paths for files
License: MIT License
Gulp plugin: remove or replace relative paths for files
License: MIT License
I'm using gulp-flatten to move bower components from it's directory into either a js/vendor and css/vendor directory, however I'm running into an issue with normalize.css. The gulp code that I'm using is
gulp.task('bower:css', function () {
gulp.src('_bower_components/**/*.css')
.pipe($.flatten())
.pipe($.rename(function(path) {
path.basename = '_' + path.basename;
path.extname = '.scss';
}))
.pipe(gulp.dest('src/assets/scss/_vendor'));
});
But when this is run it gives this error:
events.js:72
throw er; // Unhandled 'error' event
^
Error: EISDIR, open '/path/to/site/src/assets/scss/_vendor/_normalize.scss'
It seems what's throwing it off is that normalize.css has the .css in it, so it fails when it runs into this directory. Is there any way to fix this? Thanks in advance.
Hi,
is it possible to tag the current code-state?
I'd like to use this gulp-util
-free version with a pinned version.
Thanks in advance.
Robs
Hi,
it would be nice, if you would offer an option for handling files with equal names (e.g. "override" or "stop").
Cheers,
Artjom
gulp-util
has been recently deprecated. Continuing to use this dependency may prevent the use of your library with the latest release of Gulp 4 so it is important to replace gulp-util
.
The README.md lists alternatives for all the components so a simple replacement should be enough.
Your package is one of the most popular packages still relying on gulp-util
, it would be good to publish a fixed version to npm as soon as possible.
See:
First off, thanks for taking the time to make such a great tool, love it. I like the implementation of the { includeParents: 1 }
however I believe this is taking the highest level.
I was wondering what I would do to extract the next parent up, as apposed to starting at the base path. For example:
path/to/stuff/file.js
When using .pipe(flatten({ includeParents: 1 }))
on the above path, seems to bring back the first level from the top (aka path
).
build/lib/path/file.js
How would I get the path for stuff
using gulp-flatten?
build/lib/stuff/file.js
I hope you understand, hard to really explain what I mean but I did the best I could.
I'm working on an angular project and my application is split into different modules like core
and manage
. Some modules (in this example the manage
module) have additional submodules (here users
). All modules and submodules have directories for their controllers and partials.
My folder structure looks like this:
└── src
├── core
| ├── controllers
| └── partials
└── manage
├── controllers
├── partials
└── users
├── controllers
└── partials
All files from src
are compiled or copied to the folder public
that has a subfolder partials
.
Right now my task looks like this:
# coffeescript
gulp.task 'html', ->
gulp.src './src/**/*.jade', {base: './src'}
.pipe jade()
.pipe gulp.dest './public/partials'
The partials from src/core/partials/
are stored in public/partials/core/partials/
; partials from src/manage/users/partials/
in public/partials/manage/users/partials/
. The additional partials
at the end bothers me a lot.
As the transition of the first part (src/
to public/partials/
) is already handled by gulp.src
and gulp.dest
, I'm looking for a possibility to eliminate the last part of the path. As I don't know how many parents it has in total (core/partials/
vs. manage/users/partials/
) I can't achieve this with the current includeParents
option.
I suggest to use negative values as except conditions. So that includeParents: [-1, -1]
would transform part1/part2/part3/part4/
to part2/part3/
.
What do you think? I would be happy to commit a pull request.
I'd like to be able to be able to choose how deep to flatten the directory tree with an option. I'm calling the option "includeParents" since I think it's more descriptive than "depth"
To use the example from the README file, this is what the new option would look like:
var flatten = require('gulp-flatten');
gulp.src(['bower_components/**/*.min.js', 'bower_components/**/*.css'])
.pipe(flatten({ includeParents: 1} ))
.pipe(gulp.dest('build/'));
And it would create this structure:
├── angular
│ ├── angular-csp.css
│ └── angular.min.js
├── angular-route
│ └── angular-route.min.js
├── angular-sanitize
│ └── angular-sanitize.min.js
└── bootstrap
├── bootstrap-theme.css
├── bootstrap-theme.min.css
├── bootstrap.css
├── bootstrap.min.css
└── bootstrap.min.js
This would be helpful for me to keep CSS/JS/fonts all together for Bower components. Is this something you would be interested in adding/accepting PRs for?
Hey, thanks for the library.
I'm having issues using gulp-flatten. I am using
return gulp.src('./components/**/*.pug')
// .pipe(print())
.pipe(flatten())
.pipe(pug({ verbose : false }))
.pipe(gulp.dest("./../public/templates/"))
also tried
return gulp.src('./components/**/*.pug')
// .pipe(print())
.pipe(pug({ verbose : false }))
.pipe(flatten())
.pipe(gulp.dest("./../public/templates/"))
Both produce the following error:
TypeError: Cannot read property 'reduce' of undefined
at _flatten (/home/james/Code/3drepo.io/frontend/node_modules/flatten/index.js:14:16)
at flatten (/home/james/Code/3drepo.io/frontend/node_modules/flatten/index.js:11:10)
at Gulp.<anonymous> (/home/james/Code/3drepo.io/frontend/gulpfile.js:56:15)
at module.exports (/home/james/Code/3drepo.io/frontend/node_modules/orchestrator/lib/runTask.js:34:7)
at Gulp.Orchestrator._runTask (/home/james/Code/3drepo.io/frontend/node_modules/orchestrator/index.js:273:3)
at Gulp.Orchestrator._runStep (/home/james/Code/3drepo.io/frontend/node_modules/orchestrator/index.js:214:10)
at Gulp.Orchestrator.start (/home/james/Code/3drepo.io/frontend/node_modules/orchestrator/index.js:134:8)
at /usr/local/lib/node_modules/gulp/bin/gulp.js:129:20
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
Using:
Node.js LTS 6.11.2
Gulp 3.9.1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.