-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuild.js
36 lines (32 loc) · 1.11 KB
/
build.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
#!/usr/bin/env node
'use strict';
const HEADER = `<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
`
const fs = require('fs');
const jsdom = require('jsdom');
const shell = require('shelljs');
const svgToPdf = require('./svgToPdf');
const s2v = require("svg2vectordrawable");
const images = shell.ls('-R', 'icons')
.map(image => `icons/${image}`)
.filter(image => image.includes('.svg'));
for (let image of images) {
let data = HEADER + fs.readFileSync(image, 'utf-8');
fs.writeFileSync(image, data, 'utf-8');
if (image.indexOf('/ios/') != -1) {
jsdom.env({html: data,
done : function (errors, window) {
console.log(image);
var temp = svgToPdf(window.document.body);
if (temp) {
fs.writeFileSync(image.replace('.svg', '.pdf'), temp, 'utf-8');
}
}
});
} else if (image.indexOf('/android/') != -1) {
console.log(image);
s2v.svg2vectorDrawableFile(image, image.replace('.svg', '.xml'));
}
}