-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update packages and remove dependency from broccoli-webfont
https://github.com/sunflowerdeath/broccoli-webfont is no longer active Use new broccoli-caching-writer to resolve deprecation warnings Revert repository name
- Loading branch information
1 parent
ffb2378
commit d1604ad
Showing
4 changed files
with
767 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use strict'; | ||
|
||
const Plugin = require('broccoli-caching-writer') | ||
const webfontsGenerator = require('webfonts-generator'); | ||
const path = require('path'); | ||
const dirmatch = require('dirmatch'); | ||
const _ = require('underscore'); | ||
|
||
Webfont.prototype = Object.create(Plugin.prototype); | ||
Webfont.prototype.constructor = Webfont; | ||
function Webfont(inputNodes, options) { | ||
options = options || {}; | ||
Plugin.call(this, inputNodes, { | ||
annotation: options.annotation | ||
}); | ||
this.options = options; | ||
} | ||
|
||
Webfont.prototype.build = function() { | ||
const inputPath = this.inputPaths[0]; | ||
|
||
const files = dirmatch(inputPath, this.options.files); | ||
const absFiles = _.map(files, function(file) { | ||
return path.join(inputPath, file); | ||
}) | ||
|
||
const webfontsOptions = _.extend({}, this.options); | ||
webfontsOptions.files = absFiles; | ||
|
||
_.each(['dest', 'cssDest', 'htmlDest'], function(option) { | ||
let value = this.options[option]; | ||
if (value !== undefined) webfontsOptions[option] = path.join(this.outputPath, value); | ||
}, this) | ||
|
||
return new Promise(function(resolve, reject) { | ||
webfontsGenerator(webfontsOptions, function(error, result) { | ||
if (error) { | ||
reject(error); | ||
} else { | ||
resolve(result); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
Webfont.templates = webfontsGenerator.templates; | ||
|
||
module.exports = Webfont; |
Oops, something went wrong.