61 lines
2.1 KiB
JavaScript
Executable file
61 lines
2.1 KiB
JavaScript
Executable file
#!/usr/bin/env node
|
|
|
|
// This file is part of the Studyplan plugin for Moodle
|
|
//
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
|
|
/**
|
|
* This file compiles the scss files in the scss/ folder into either the main
|
|
* styles.css for production upon build or css/devstyles.css for development
|
|
*
|
|
* Most nice would be to integrate this action with grunt watch, but I am
|
|
* not familiar enough with grunt to know if I can extend moodle's grunt actions
|
|
* from a Gruntfile.js in this directory without modifying Moodle's Gruntfile.js
|
|
*
|
|
* @package local_treestudyplan
|
|
* @copyright 2023 P.M. Kuipers
|
|
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
*/
|
|
|
|
const sass = require('sass');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
|
|
const output = 'css/devstyles.css';
|
|
|
|
let css = "";
|
|
let map = "";
|
|
//joining path of directory
|
|
const directoryPath = path.join(__dirname, 'scss');
|
|
//passsing directoryPath and callback function
|
|
fs.readdir(directoryPath, function (err, files) {
|
|
//handling error
|
|
if (err) {
|
|
return console.log('Unable to scan directory: ' + err);
|
|
}
|
|
//listing all files using forEach
|
|
files.forEach(function (file) {
|
|
const result = sass.compile(file);
|
|
console.info(`Processing ${file}...`)
|
|
if ( result ) {
|
|
css = css + `/**** ${file} ****/\n` + result.css + "\n";
|
|
}
|
|
});
|
|
|
|
console.info(`Storing ${output}`);
|
|
fs.writeFile(path.join(__dirname, output),css,(err) => {
|
|
if (err) throw err;
|
|
});
|
|
|
|
});
|
|
|