Add dart and node sass tests

This commit is contained in:
Jeremy Thomas 2020-11-07 17:19:18 +00:00
parent a22fecb94d
commit f659047462
4 changed files with 158 additions and 67 deletions

View File

@ -1,79 +1,40 @@
const fs = require('fs');
const path = require('path');
const sass = require('sass'); const sass = require('sass');
const utils = require('./utils');
const sources = [ const DART_BASE_PATH = 'test/build/dart-sass/';
`base/animations.sass`,
`base/generic.sass`,
`base/minireset.sass`,
`components/breadcrumb.sass`, fs.mkdir(DART_BASE_PATH, { recursive: true }, (err) => {
`components/card.sass`, if (err) throw err;
`components/dropdown.sass`, });
`components/level.sass`,
`components/media.sass`, const exportDartCSS = (filepath, options) => {
`components/menu.sass`, utils.exportCSS(sass, fs, DART_BASE_PATH, filepath, options)
`components/message.sass`, }
`components/modal.sass`,
`components/navbar.sass`, // Full import
`components/pagination.sass`,
`components/panel.sass`, exportDartCSS('bulma', {
`components/tabs.sass`, file: './bulma.sass',
});
`elements/box.sass`,
`elements/button.sass`, exportDartCSS('bulma-rtl', {
`elements/container.sass`, file: './bulma-rtl.sass',
`elements/content.sass`, });
`elements/icon.sass`,
`elements/image.sass`, // Single imports
`elements/notification.sass`,
`elements/other.sass`, const BULMA_IMPORT_PATH = `./sass/`;
`elements/progress.sass`,
`elements/table.sass`, utils.SOURCES.forEach((source) => {
`elements/tag.sass`, const parsed = path.parse(source);
`elements/title.sass`,
fs.mkdir(`${DART_BASE_PATH}${parsed.dir}`, { recursive: true }, (err) => {
`form/checkbox-radio.sass`, if (err) throw err;
`form/file.sass`, });
`form/input-textarea.sass`,
`form/select.sass`, exportDartCSS(`${parsed.dir}/${parsed.name}`, {
`form/tools.sass`, data: `@use "${BULMA_IMPORT_PATH}${source}";`,
});
`grid/columns.sass`,
`grid/tiles.sass`,
`helpers/color.sass`,
`helpers/flexbox.sass`,
`helpers/float.sass`,
`helpers/other.sass`,
`helpers/overflow.sass`,
`helpers/position.sass`,
`helpers/spacing.sass`,
`helpers/typography.sass`,
`helpers/visibility.sass`,
`layout/footer.sass`,
`layout/hero.sass`,
`layout/section.sass`,
`utilities/controls.sass`,
`utilities/derived-variables.sass`,
`utilities/functions.sass`,
`utilities/initial-variables.sass`,
`utilities/mixins.sass`,
];
const BULMA_SASS_PATH = `./sass/`;
sources.forEach(source => {
const result = sass.renderSync({
data: `@use "${BULMA_SASS_PATH}${source}";`,
outputStyle: "expanded"
});
try {
sass.renderSync({
data: `@use "${BULMA_SASS_PATH}${source}";`,
});
} catch(err) {
console.error(err);
}
}); });

40
test/node-sass.js Normal file
View File

@ -0,0 +1,40 @@
const fs = require('fs');
const path = require('path');
const sass = require('node-sass');
const utils = require('./utils');
const NODE_SASS_BASE_PATH = 'test/build/node-sass/';
fs.mkdir(NODE_SASS_BASE_PATH, { recursive: true }, (err) => {
if (err) throw err;
});
const exportNodeSassCSS = (filepath, options) => {
utils.exportCSS(sass, fs, NODE_SASS_BASE_PATH, filepath, options)
}
// Full import
exportNodeSassCSS('bulma', {
file: './bulma.sass',
});
exportNodeSassCSS('bulma-rtl', {
file: './bulma-rtl.sass',
});
// Single imports
const BULMA_IMPORT_PATH = `./sass/`;
utils.SOURCES.forEach((source) => {
const parsed = path.parse(source);
fs.mkdir(`${NODE_SASS_BASE_PATH}${parsed.dir}`, { recursive: true }, (err) => {
if (err) throw err;
});
exportNodeSassCSS(`${parsed.dir}/${parsed.name}`, {
data: `@use "${BULMA_IMPORT_PATH}${source}";`,
});
});

View File

@ -4,8 +4,8 @@
TEST_DIR=$(dirname $BASH_SOURCE) TEST_DIR=$(dirname $BASH_SOURCE)
FILES=$TEST_DIR/sass/* FILES=$TEST_DIR/sass/*
CSS_DIR=$TEST_DIR/css CSS_DIR=$TEST_DIR/build/ruby-sass
CSS_FILES=$TEST_DIR/css/*.css CSS_FILES=$TEST_DIR/build/ruby-sass/*.css
SASS_OPTIONS=--sourcemap=none SASS_OPTIONS=--sourcemap=none
# FUNCTIONS # FUNCTIONS

90
test/utils.js Normal file
View File

@ -0,0 +1,90 @@
module.exports = Object.freeze({
SOURCES: [
`base/animations.sass`,
`base/generic.sass`,
`base/minireset.sass`,
`components/breadcrumb.sass`,
`components/card.sass`,
`components/dropdown.sass`,
`components/level.sass`,
`components/media.sass`,
`components/menu.sass`,
`components/message.sass`,
`components/modal.sass`,
`components/navbar.sass`,
`components/pagination.sass`,
`components/panel.sass`,
`components/tabs.sass`,
`elements/box.sass`,
`elements/button.sass`,
`elements/container.sass`,
`elements/content.sass`,
`elements/icon.sass`,
`elements/image.sass`,
`elements/notification.sass`,
`elements/other.sass`,
`elements/progress.sass`,
`elements/table.sass`,
`elements/tag.sass`,
`elements/title.sass`,
`form/checkbox-radio.sass`,
`form/file.sass`,
`form/input-textarea.sass`,
`form/select.sass`,
`form/tools.sass`,
`grid/columns.sass`,
`grid/tiles.sass`,
`helpers/color.sass`,
`helpers/flexbox.sass`,
`helpers/float.sass`,
`helpers/other.sass`,
`helpers/overflow.sass`,
`helpers/position.sass`,
`helpers/spacing.sass`,
`helpers/typography.sass`,
`helpers/visibility.sass`,
`layout/footer.sass`,
`layout/hero.sass`,
`layout/section.sass`,
`utilities/controls.sass`,
`utilities/derived-variables.sass`,
`utilities/functions.sass`,
`utilities/initial-variables.sass`,
`utilities/mixins.sass`,
],
buildCSS: (fn, name, options) => {
try {
console.log(`Processing ${name}`);
fn.renderSync(options);
} catch (err) {
console.log(`Error with ${name}`);
console.error(err);
}
},
exportCSS: (fn, fs, basepath, filepath, options) => {
const exportFile = `${basepath}${filepath}.css`;
fn.render(
{
...options,
outFile: exportFile,
},
(error, result) => {
if (!error) {
fs.writeFile(exportFile, result.css, (err) => {
if (!err) {
console.log(`File ${exportFile} written on disk`);
}
});
}
}
);
}
});