Fixed exports (again).

This commit is contained in:
flash 2024-06-10 02:33:07 +00:00
parent bb0ac94751
commit 0e09f06b02
10 changed files with 16 additions and 14 deletions

View file

@ -3,7 +3,7 @@ const readline = require('readline');
const { join: pathJoin } = require('path');
const { trim, trimStart, trimEnd } = require('./trim.js');
exports.folder = async (root, options) => {
module.exports.folder = async (root, options) => {
const macroPrefix = options.prefix || '#';
const entryPoint = options.entry || '';

View file

@ -3,7 +3,7 @@ const combine = require('../combine.js');
const { join: pathJoin, dirname } = require('path');
const { strtr, shortHash, writeFile } = require('../utils.js');
exports = function(env) {
module.exports = function(env) {
const PREFIX = '@';
const DEFAULT_ENTRY = 'main.css';

View file

@ -2,7 +2,7 @@ const { minify: htmlminify } = require('html-minifier-terser');
const { join: pathJoin, dirname } = require('path');
const { strtr, shortHash, writeFile } = require('../utils.js');
exports = function(env) {
module.exports = function(env) {
const MINIFY_OPTS = {
collapseBooleanAttributes: true,
collapseWhitespace: true,

View file

@ -4,7 +4,7 @@ const { minify: htmlminify } = require('html-minifier-terser');
const { join: pathJoin, } = require('path');
const { strtr, shortHash, writeFile } = require('../utils.js');
exports = function(env) {
module.exports = function(env) {
const PREFIX = '#';
const DEFAULT_ENTRY = 'main.js';
const DEFAULT_VARS_TARGET = 'window';

View file

@ -3,7 +3,7 @@ const { minify: htmlminify } = require('html-minifier-terser');
const { join: pathJoin, dirname } = require('path');
const { strtr, shortHash, writeFile } = require('../utils.js');
exports = function(env) {
module.exports = function(env) {
const MINIFY_OPTS = {
collapseBooleanAttributes: true,
collapseWhitespace: true,

View file

@ -2,7 +2,7 @@ const fs = require('fs');
const { join: pathJoin, dirname } = require('path');
const { strtr, shortHash, writeFile } = require('../utils.js');
exports = function(env) {
module.exports = function(env) {
return {
process: async (task, vars) => {
let body = JSON.parse(fs.readFileSync(pathJoin(env.source, task.source)));

View file

@ -1,7 +1,7 @@
const fs = require('fs');
const { join: pathJoin } = require('path');
exports.housekeep = path => {
module.exports.housekeep = path => {
const files = fs.readdirSync(path).map(fileName => {
const stats = fs.statSync(pathJoin(path, fileName));
return {

View file

@ -23,7 +23,7 @@ const DEFAULT_ENV = {
},
};
exports.process = async (env, tasks) => {
module.exports.process = async (env, tasks) => {
if(typeof env.source !== 'string')
throw 'env.source must be a path to the source directories';
if(typeof env.public !== 'string')

View file

@ -16,6 +16,8 @@ const trim = (str, chars = " \n\r\t\v\0", flags = 0) => {
return str;
};
exports.trimStart = (str, chars) => trim(str, chars, 0x01);
exports.trimEnd = (str, chars) => trim(str, chars, 0x02);
exports.trim = (str, chars) => trim(str, chars, 0x03);
module.exports = {
trimStart: (str, chars) => trim(str, chars, 0x01),
trimEnd: (str, chars) => trim(str, chars, 0x02),
trim: (str, chars) => trim(str, chars, 0x03),
}

View file

@ -2,17 +2,17 @@ const crypto = require('crypto');
const fs = require('fs');
const { dirname } = require('path');
exports.strtr = (str, replacements) => str.toString().replace(
module.exports.strtr = (str, replacements) => str.toString().replace(
/{([^}]+)}/g, (match, key) => replacements[key] || match
);
exports.shortHash = text => {
module.exports.shortHash = text => {
const hash = crypto.createHash('sha256');
hash.update(text);
return hash.digest('hex').substring(0, 8);
};
exports.writeFile = (path, data) => {
module.exports.writeFile = (path, data) => {
const folderPath = dirname(path);
if(!fs.existsSync(folderPath))
fs.mkdirSync(folderPath, { recursive: true });