New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
output paramater is ignored, original images are overwritten #163
Comments
If you log |
https://github.com/imagemin/imagemin/blob/master/index.js#L11 |
@QuentinFchx, happy if you could add a failing test. |
test('should output at the specified location', async t => {
const files1 = await m(['fixture.jpg'], 'output', {use: imageminJpegtran()});
const files2 = await m(['output/*.jpg'], 'output', {use: imageminJpegtran()});
t.is(path.relative(__dirname, files1[0].path), 'output/fixture.jpg');
t.is(path.relative(__dirname, files2[0].path), 'output/fixture.jpg'); // will fail
}); |
I'm having the same issue. |
We might want to use https://github.com/contra/glob2base. |
Will try it and see what I come up with. |
@QuentinFchx @currentrame @ldanet, I think #175 should fix it. |
@kevva It works for simple patterns, but when you're using globstars ( |
Isn't this exactly what you wrote earlier? |
I wrote a specific test case that is fixed by your commit, however I forgot to mention this case can be extended. Let's take the following use case: I want to process
TLDR; The issue is that we lose the reference of the "matching" part of the glob. For each file, we want to separate the "static" part of the glob ( Prior to 5.0.0 version, we were using vinyl-fs that used to keep that "matching pattern". It does not seem possible to achieve with globby alone. |
Do we want that as the default behavior or behind an option? We only need to do this (I think) in any case https://github.com/sindresorhus/cpy/blob/master/index.js#L36, and maybe remove the matching parts. |
I think my path-union does the trick: from - const dest = output ? path.join(output, path.basename(input)) : null;
+ const dest = output ? union(path.resolve(output), path.resolve(input)) : null; running λ find images
images
images/fixture-corrupt.jpg
images/test
images/test/fixture.jpg λ find output
output
output/images
output/images/fixture-corrupt.jpg
output/images/test
output/images/test/fixture.jpg |
imagemin v5.0.0
imagemin-pngquant v5.0.0
code:
const imagemin = require('imagemin'); var pngComp = require("imagemin-pngquant"); imagemin(['/Users/m/projects/m/_test/tmp/in/*.{jpg,png}'], '/Users/m/projects/m/_test/tmp/out', { use: [ pngComp({quality: '65-80'}) ] }).then(files => { console.log(files); });
The text was updated successfully, but these errors were encountered: