Skip to content

Commit 7040e49

Browse files
committed
lint: group preprocess in sub-routines
1 parent 04096de commit 7040e49

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed

tasks/preprocess.js

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,45 @@
11
var fs = require('fs-extra');
2-
32
var sass = require('node-sass');
43

4+
var constants = require('./util/constants');
5+
var common = require('./util/common');
56
var pullCSS = require('./util/pull_css');
67
var pullFontSVG = require('./util/pull_font_svg');
78
var updateVersion = require('./util/update_version');
8-
var constants = require('./util/constants');
99

10+
// main
11+
makeBuildCSS();
12+
makeBuildFontSVG();
13+
copyTopojsonFiles();
14+
updateVersion(constants.pathToPlotlyCore);
15+
updateVersion(constants.pathToPlotlyGeoAssetsSrc);
1016

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;
1724

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+
}
2129

2230
// 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;
2634

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+
}
3238

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(constants.pathToTopojsonSrc, constants.pathToTopojsonDist,
42+
{ clobber: true },
43+
common.throwOnError
44+
);
45+
}

0 commit comments

Comments
 (0)