/
helper.js
52 lines (44 loc) · 1.08 KB
/
helper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* imacss
*
* Copyright(c) 2014 André König <andre.koenig@posteo.de>
* MIT Licensed
*
*/
/**
* @author André König <andre.koenig@posteo.de>
*
*/
'use strict';
var fs = require('fs');
var path = require('path');
var gutil = require('gulp-util');
/**
* Creates a vinyl based file description.
*
* @return {object} A vinyl file description based on a SVG in the assets directory.
*
*/
exports.createImageFile = function createImageFile () {
var svg = './specs/assets/twitter.svg';
return new gutil.File({
path: svg,
cwd: './specs/assets/',
base: './specs/assets/',
contents: fs.readFileSync(svg)
});
};
/**
* Creates an example of the internal image data structure.
*
* @return {object} The internal image data structure based on a SVG in the assets directory.
*
*/
exports.createImage = function createImage () {
var file = this.createImageFile();
var image = {};
image.name = path.basename(file.path);
image.contents = file.contents;
image.base64 = file.contents.toString('base64');
return image;
};