first commit
This commit is contained in:
72
build/node_modules/imagemin/index.js
generated
vendored
Normal file
72
build/node_modules/imagemin/index.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const fileType = require('file-type');
|
||||
const globby = require('globby');
|
||||
const makeDir = require('make-dir');
|
||||
const pify = require('pify');
|
||||
const pPipe = require('p-pipe');
|
||||
const replaceExt = require('replace-ext');
|
||||
|
||||
const fsP = pify(fs);
|
||||
|
||||
const handleFile = (input, output, opts) => fsP.readFile(input).then(data => {
|
||||
const dest = output ? path.join(output, path.basename(input)) : null;
|
||||
|
||||
if (opts.plugins && !Array.isArray(opts.plugins)) {
|
||||
throw new TypeError('The plugins option should be an `Array`');
|
||||
}
|
||||
|
||||
const pipe = opts.plugins.length > 0 ? pPipe(opts.plugins)(data) : Promise.resolve(data);
|
||||
|
||||
return pipe
|
||||
.then(buf => {
|
||||
buf = buf.length < data.length ? buf : data;
|
||||
|
||||
const ret = {
|
||||
data: buf,
|
||||
path: (fileType(buf) && fileType(buf).ext === 'webp') ? replaceExt(dest, '.webp') : dest
|
||||
};
|
||||
|
||||
if (!dest) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return makeDir(path.dirname(ret.path))
|
||||
.then(() => fsP.writeFile(ret.path, ret.data))
|
||||
.then(() => ret);
|
||||
})
|
||||
.catch(err => {
|
||||
err.message = `Error in file: ${input}\n\n${err.message}`;
|
||||
throw err;
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = (input, output, opts) => {
|
||||
if (!Array.isArray(input)) {
|
||||
return Promise.reject(new TypeError('Expected an array'));
|
||||
}
|
||||
|
||||
if (typeof output === 'object') {
|
||||
opts = output;
|
||||
output = null;
|
||||
}
|
||||
|
||||
opts = Object.assign({plugins: []}, opts);
|
||||
opts.plugins = opts.use || opts.plugins;
|
||||
|
||||
return globby(input, {nodir: true}).then(paths => Promise.all(paths.map(x => handleFile(x, output, opts))));
|
||||
};
|
||||
|
||||
module.exports.buffer = (input, opts) => {
|
||||
if (!Buffer.isBuffer(input)) {
|
||||
return Promise.reject(new TypeError('Expected a buffer'));
|
||||
}
|
||||
|
||||
opts = Object.assign({plugins: []}, opts);
|
||||
opts.plugins = opts.use || opts.plugins;
|
||||
|
||||
const pipe = opts.plugins.length > 0 ? pPipe(opts.plugins)(input) : Promise.resolve(input);
|
||||
|
||||
return pipe.then(buf => buf.length < input.length ? buf : input);
|
||||
};
|
||||
21
build/node_modules/imagemin/license
generated
vendored
Normal file
21
build/node_modules/imagemin/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) imagemin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
95
build/node_modules/imagemin/package.json
generated
vendored
Normal file
95
build/node_modules/imagemin/package.json
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"imagemin@5.3.1",
|
||||
"/Users/asciidisco/Desktop/asciidisco.com/build"
|
||||
]
|
||||
],
|
||||
"_from": "imagemin@5.3.1",
|
||||
"_id": "imagemin@5.3.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-8Zwu7h5xumxlWMUV+fyWaAGJptQ=",
|
||||
"_location": "/imagemin",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "imagemin@5.3.1",
|
||||
"name": "imagemin",
|
||||
"escapedName": "imagemin",
|
||||
"rawSpec": "5.3.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "5.3.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/imagemin/-/imagemin-5.3.1.tgz",
|
||||
"_spec": "5.3.1",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build",
|
||||
"author": {
|
||||
"name": "Kevin Mårtensson",
|
||||
"email": "kevinmartensson@gmail.com",
|
||||
"url": "github.com/kevva"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/imagemin/imagemin/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"file-type": "^4.1.0",
|
||||
"globby": "^6.1.0",
|
||||
"make-dir": "^1.0.0",
|
||||
"p-pipe": "^1.1.0",
|
||||
"pify": "^2.3.0",
|
||||
"replace-ext": "^1.0.0"
|
||||
},
|
||||
"description": "Minify images",
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"del": "^2.2.0",
|
||||
"imagemin-jpegtran": "^5.0.0",
|
||||
"imagemin-webp": "^4.0.0",
|
||||
"is-jpg": "^1.0.0",
|
||||
"tempy": "^0.1.0",
|
||||
"xo": "*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/imagemin/imagemin#readme",
|
||||
"keywords": [
|
||||
"minify",
|
||||
"compress",
|
||||
"image",
|
||||
"images",
|
||||
"jpeg",
|
||||
"jpg",
|
||||
"png",
|
||||
"gif",
|
||||
"svg"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
{
|
||||
"name": "Shinnosuke Watanabe",
|
||||
"url": "github.com/shinnn"
|
||||
}
|
||||
],
|
||||
"name": "imagemin",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/imagemin/imagemin.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"version": "5.3.1"
|
||||
}
|
||||
91
build/node_modules/imagemin/readme.md
generated
vendored
Normal file
91
build/node_modules/imagemin/readme.md
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
# imagemin [](https://travis-ci.org/imagemin/imagemin) [](https://ci.appveyor.com/project/ShinnosukeWatanabe/imagemin)
|
||||
|
||||
> Minify images seamlessly
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save imagemin
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const imagemin = require('imagemin');
|
||||
const imageminJpegtran = require('imagemin-jpegtran');
|
||||
const imageminPngquant = require('imagemin-pngquant');
|
||||
|
||||
imagemin(['images/*.{jpg,png}'], 'build/images', {
|
||||
plugins: [
|
||||
imageminJpegtran(),
|
||||
imageminPngquant({quality: '65-80'})
|
||||
]
|
||||
}).then(files => {
|
||||
console.log(files);
|
||||
//=> [{data: <Buffer 89 50 4e …>, path: 'build/images/foo.jpg'}, …]
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### imagemin(input, output, [options])
|
||||
|
||||
Returns `Promise<Object[]>` in the format `{data: Buffer, path: String}`.
|
||||
|
||||
#### input
|
||||
|
||||
Type: `Array`
|
||||
|
||||
Files to be optimized. See supported `minimatch` [patterns](https://github.com/isaacs/minimatch#usage).
|
||||
|
||||
#### output
|
||||
|
||||
Type: `string`
|
||||
|
||||
Set the destination folder to where your files will be written. If no destination is specified no files will be written.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object`
|
||||
|
||||
##### plugins
|
||||
|
||||
Type: `Array`
|
||||
|
||||
[Plugins](https://www.npmjs.com/browse/keyword/imageminplugin) to use.
|
||||
|
||||
### imagemin.buffer(buffer, [options])
|
||||
|
||||
Returns `Promise<Buffer>`.
|
||||
|
||||
#### buffer
|
||||
|
||||
Type: `Buffer`
|
||||
|
||||
Buffer to optimize.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object`
|
||||
|
||||
##### plugins
|
||||
|
||||
Type: `Array`
|
||||
|
||||
[Plugins](https://www.npmjs.com/browse/keyword/imageminplugin) to use.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [imagemin-cli](https://github.com/imagemin/imagemin-cli) - CLI for this module
|
||||
- [imagemin-app](https://github.com/imagemin/imagemin-app) - GUI app for this module
|
||||
- [gulp-imagemin](https://github.com/sindresorhus/gulp-imagemin) - Gulp plugin
|
||||
- [grunt-contrib-imagemin](https://github.com/gruntjs/grunt-contrib-imagemin) - Grunt plugin
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [imagemin](https://github.com/imagemin)
|
||||
Reference in New Issue
Block a user