forked from code-dot-org/code-dot-org
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-css.js
More file actions
executable file
·63 lines (55 loc) · 1.77 KB
/
Copy pathbuild-css.js
File metadata and controls
executable file
·63 lines (55 loc) · 1.77 KB
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
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env node
/** @file Build script for CSS assets in the code-studio package, which is loaded
by dashboard (our "Code Studio" Rails app). */
/* global Promise */
'use strict';
var commander = require('commander');
var commands = require('./build-commands');
var path = require('path');
var ensureDirectoryExists = commands.ensureDirectoryExists;
var executeShellCommandsInParallel = commands.executeShellCommandsInParallel;
var logSuccess = commands.logSuccess;
var logFailure = commands.logFailure;
/** @const {string} */
var SRC_PATH = './src/css/';
/** @const {string} */
var BUILD_PATH = './build/css/';
/** @const {string[]} */
var FILES = [
'levelbuilder.scss',
'leveltype_widget.scss',
'plc.scss',
'pd.scss'
];
/**
* Paths to search when evaluating scss @import directives.
* Rooted at code-studio root, with NO trailing slash.
* @const {string[]}
*/
var INCLUDE_PATHS = [
'node_modules',
'src/css',
'../shared/css'
];
// Use commander to parse command line arguments
// https://github.com/tj/commander.js
commander
.option('--dist', 'Build output optimized for distribution', false)
.parse(process.argv);
// Build up list of shell commands to run SASS on each file
var includePathArguments = INCLUDE_PATHS.map(function (path) {
return '--include-path ' + path;
}).join(" \\\n ");
var sassCommands = FILES.map(function (file) {
return [
'node-sass' + (commander.dist ? ' --output-style compressed' : ''),
includePathArguments,
SRC_PATH + file,
BUILD_PATH + path.basename(file, '.scss') + '.css'
].join(" \\\n ");
});
Promise.resolve()
.then(ensureDirectoryExists(BUILD_PATH))
.then(executeShellCommandsInParallel(sassCommands))
.then(logSuccess("code-studio css built"))
.catch(logFailure("code-studio css failed"));