|
1 | 1 | var fs = require('fs-extra'); |
2 | | - |
3 | 2 | var sass = require('node-sass'); |
4 | 3 |
|
| 4 | +var constants = require('./util/constants'); |
| 5 | +var common = require('./util/common'); |
5 | 6 | var pullCSS = require('./util/pull_css'); |
6 | 7 | var pullFontSVG = require('./util/pull_font_svg'); |
7 | 8 | var updateVersion = require('./util/update_version'); |
8 | | -var constants = require('./util/constants'); |
9 | 9 |
|
| 10 | +// main |
| 11 | +makeBuildCSS(); |
| 12 | +makeBuildFontSVG(); |
| 13 | +copyTopojsonFiles(); |
| 14 | +updateVersion(constants.pathToPlotlyCore); |
| 15 | +updateVersion(constants.pathToPlotlyGeoAssetsSrc); |
10 | 16 |
|
11 | | -// convert scss to css |
12 | | -sass.render({ |
13 | | - file: constants.pathToSCSS, |
14 | | - outputStyle: 'compressed' |
15 | | -}, function(err, result) { |
16 | | - if(err) console.log('SASS error'); |
| 17 | +// convert scss to css to js |
| 18 | +function makeBuildCSS() { |
| 19 | + sass.render({ |
| 20 | + file: constants.pathToSCSS, |
| 21 | + outputStyle: 'compressed' |
| 22 | + }, function(err, result) { |
| 23 | + if(err) throw err; |
17 | 24 |
|
18 | | - // css to js |
19 | | - pullCSS(String(result.css), constants.pathToCSSBuild); |
20 | | -}); |
| 25 | + // css to js |
| 26 | + pullCSS(String(result.css), constants.pathToCSSBuild); |
| 27 | + }); |
| 28 | +} |
21 | 29 |
|
22 | 30 | // convert font svg into js |
23 | | -fs.readFile(constants.pathToFontSVG, function(err, data) { |
24 | | - pullFontSVG(data.toString(), constants.pathToFontSVGBuild); |
25 | | -}); |
| 31 | +function makeBuildFontSVG() { |
| 32 | + fs.readFile(constants.pathToFontSVG, function(err, data) { |
| 33 | + if(err) throw err; |
26 | 34 |
|
27 | | -// copy topojson files from sane-topojson to dist/ |
28 | | -fs.copy(constants.pathToTopojsonSrc, constants.pathToTopojsonDist, |
29 | | - { clobber: true }, |
30 | | - function(err) { if(err) throw err; } |
31 | | -); |
| 35 | + pullFontSVG(data.toString(), constants.pathToFontSVGBuild); |
| 36 | + }); |
| 37 | +} |
32 | 38 |
|
33 | | -// inject package version into source index files |
34 | | -updateVersion(constants.pathToPlotlyCore); |
35 | | -updateVersion(constants.pathToPlotlyGeoAssetsSrc); |
| 39 | +// copy topojson files from sane-topojson to dist/ |
| 40 | +function copyTopojsonFiles() { |
| 41 | + fs.copy( |
| 42 | + constants.pathToTopojsonSrc, |
| 43 | + constants.pathToTopojsonDist, |
| 44 | + { clobber: true }, |
| 45 | + common.throwOnError |
| 46 | + ); |
| 47 | +} |
0 commit comments