Socket
Socket
Sign inDemoInstall

webpack-webfont

Package Overview
Dependencies
286
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.1-alpha.1 to 0.0.1-alpha.2

4

CHANGELOG.md

@@ -0,3 +1,7 @@

# 0.0.1-alpha.2 - 2016-11-07
- Fixed: problems with `watch`.
# 0.0.1-alpha.1 - 2016-10-31
- Chore: initial public release.

227

dist/Plugin.js

@@ -7,2 +7,4 @@ 'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _chokidar = require('chokidar');

@@ -26,127 +28,112 @@

function WebfontPlugin(options) {
this.errors = [];
this.options = options;
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
WebfontPlugin.prototype = {
apply: function apply(compiler) {
var _this = this;
var WebfontPlugin = function () {
function WebfontPlugin() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
compiler.plugin('run', function (compilerInstance, callback) {
return _this.compile(callback);
});
_classCallCheck(this, WebfontPlugin);
var watchStarted = false;
this.options = options;
this.errors = [];
this.watch = false;
}
compiler.plugin('watch-run', function (watching, watchRunCallback) {
if (watchStarted) {
return watchRunCallback();
}
_createClass(WebfontPlugin, [{
key: 'apply',
value: function apply(compiler) {
var _this = this;
watchStarted = true;
return _chokidar2.default.watch(_this.options.files).on('all', function () {
return _this.compile(watchRunCallback);
compiler.plugin('run', function (compilerInstance, done) {
return _this.compile(done);
});
});
compiler.plugin('compilation', function (compilation) {
compilation.errors = compilation.errors.concat(_this.errors);
});
},
compile: function compile(callback) {
var _this2 = this;
compiler.plugin('watch-run', function (watching, done) {
if (_this.watch) {
return done();
}
var options = this.options;
_this.watch = true;
if (!options.dest) {
this.errors.push(new Error('Require "dest" argument'));
// eslint-disable-next-line no-empty-function
_chokidar2.default.watch(_this.options.files).on('all', function () {
return _this.compile(function () {});
});
return callback();
}
return _this.compile(done);
});
if (!options.dest.fontsDir) {
this.errors.push(new Error('Require "fonts" property for "dest" argument'));
return callback();
compiler.plugin('compilation', function (compilation) {
compilation.errors = compilation.errors.concat(_this.errors);
});
}
}, {
key: 'compile',
value: function compile(callback) {
var _this2 = this;
if (options.css && !options.dest.css) {
this.errors.push(new Error('Require "css" property for "dest" argument if you passed "true" "css" argument'));
var options = this.options;
return callback();
}
if (!options.dest) {
this.errors.push(new Error('Require "dest" argument'));
return (0, _webfont2.default)(options).then(function (result) {
var promisesFs = [];
var fontsDest = options.dest.fontsDir;
var fontName = result.config.fontName;
return callback();
}
if (result.svg) {
promisesFs.push(new Promise(function (resolve, reject) {
return _fsExtra2.default.outputFile(_path2.default.join(fontsDest, fontName + '.svg'), result.svg, function (error) {
if (error) {
return reject(error);
}
if (!options.dest.fontsDir) {
this.errors.push(new Error('Require "fonts" property for "dest" argument'));
return resolve();
});
}));
return callback();
}
if (result.ttf) {
promisesFs.push(new Promise(function (resolve, reject) {
return _fsExtra2.default.outputFile(_path2.default.join(fontsDest, fontName + '.ttf'), result.ttf, function (error) {
if (error) {
return reject(error);
}
if (options.css && !options.dest.css) {
this.errors.push(new Error('Require "css" property for "dest" argument if you passed "true" "css" argument'));
return resolve();
});
}));
return callback();
}
if (result.eot) {
promisesFs.push(new Promise(function (resolve, reject) {
return _fsExtra2.default.outputFile(_path2.default.join(fontsDest, fontName + '.eot'), result.eot, function (error) {
if (error) {
return reject(error);
}
return (0, _webfont2.default)(options).then(function (result) {
var promisesFs = [];
var fontsDest = options.dest.fontsDir;
var fontName = result.config.fontName;
return resolve();
});
}));
}
if (result.svg) {
promisesFs.push(new Promise(function (resolve, reject) {
return _fsExtra2.default.outputFile(_path2.default.join(fontsDest, fontName + '.svg'), result.svg, function (error) {
if (error) {
return reject(error);
}
if (result.woff) {
promisesFs.push(new Promise(function (resolve, reject) {
return _fsExtra2.default.outputFile(_path2.default.join(fontsDest, fontName + '.woff'), result.woff, function (error) {
if (error) {
return reject(error);
}
return resolve();
});
}));
}
return resolve();
});
}));
}
if (result.ttf) {
promisesFs.push(new Promise(function (resolve, reject) {
return _fsExtra2.default.outputFile(_path2.default.join(fontsDest, fontName + '.ttf'), result.ttf, function (error) {
if (error) {
return reject(error);
}
if (result.woff2) {
promisesFs.push(new Promise(function (resolve, reject) {
return _fsExtra2.default.outputFile(_path2.default.join(fontsDest, fontName + '.woff2'), result.woff2, function (error) {
if (error) {
return reject(error);
}
return resolve();
});
}));
}
return resolve();
});
}));
}
if (result.eot) {
promisesFs.push(new Promise(function (resolve, reject) {
return _fsExtra2.default.outputFile(_path2.default.join(fontsDest, fontName + '.eot'), result.eot, function (error) {
if (error) {
return reject(error);
}
if (result.css) {
(function () {
var cssDest = options.dest.css;
return resolve();
});
}));
}
if (result.woff) {
promisesFs.push(new Promise(function (resolve, reject) {
return _fsExtra2.default.outputFile(cssDest, result.css, function (error) {
return _fsExtra2.default.outputFile(_path2.default.join(fontsDest, fontName + '.woff'), result.woff, function (error) {
if (error) {

@@ -159,15 +146,45 @@ return reject(error);

}));
})();
}
}
return Promise.all(promisesFs).then(function () {
return callback();
if (result.woff2) {
promisesFs.push(new Promise(function (resolve, reject) {
return _fsExtra2.default.outputFile(_path2.default.join(fontsDest, fontName + '.woff2'), result.woff2, function (error) {
if (error) {
return reject(error);
}
return resolve();
});
}));
}
if (result.css) {
(function () {
var cssDest = options.dest.css;
promisesFs.push(new Promise(function (resolve, reject) {
return _fsExtra2.default.outputFile(cssDest, result.css, function (error) {
if (error) {
return reject(error);
}
return resolve();
});
}));
})();
}
return Promise.all(promisesFs).then(function () {
return callback();
});
}).catch(function (error) {
_this2.errors.push(error);
callback();
});
}).catch(function (error) {
_this2.errors.push(error);
callback();
});
}
};
}
}]);
return WebfontPlugin;
}();
exports.default = WebfontPlugin;
{
"name": "webpack-webfont",
"version": "0.0.1-alpha.1",
"version": "0.0.1-alpha.2",
"description": "Webpack plugin for webfont package",

@@ -52,3 +52,3 @@ "license": "MIT",

"webfont": "^6.0.0",
"fs-extra": "^0.30.0",
"fs-extra": "^1.0.0",
"chokidar": "^1.6.0"

@@ -69,13 +69,13 @@ },

"del-cli": "^0.2.0",
"eslint": "^3.4.0",
"eslint-plugin-ava": "^3.0.0",
"eslint-plugin-import": "^2.0.0",
"eslint-plugin-itgalaxy": "^23.0.0",
"eslint": "^3.9.1",
"eslint-plugin-ava": "^4.0.0",
"eslint-plugin-import": "^2.1.0",
"eslint-plugin-itgalaxy": "^25.0.0",
"eslint-plugin-jsx-a11y": "^2.2.0",
"eslint-plugin-lodash": "^2.1.0",
"eslint-plugin-node": "^2.0.0",
"eslint-plugin-promise": "^3.0.0",
"eslint-plugin-react": "^6.2.0",
"eslint-plugin-node": "^3.0.0",
"eslint-plugin-promise": "^3.3.0",
"eslint-plugin-react": "^6.5.0",
"eslint-plugin-unicorn": "^1.0.0",
"file-loader": "^0.8.0",
"file-loader": "^0.9.0",
"npmpub": "^3.1.0",

@@ -87,3 +87,3 @@ "npm-run-all": "^3.0.0",

"remark-lint": "^5.0.0",
"remark-preset-lint-itgalaxy": "^2.0.0",
"remark-preset-lint-itgalaxy": "^3.0.0",
"style-loader": "^0.13.0",

@@ -90,0 +90,0 @@ "webpack": "^1.13.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc