Comparing version 0.1.2 to 0.2.0
24
cli.js
#!/usr/bin/env node | ||
const chokidar = require('chokidar'); | ||
const chalk = require('chalk'); | ||
@@ -9,31 +8,14 @@ const yargs = require('yargs/yargs'); | ||
const { getDirFromPath } = require('./lib/helpers'); | ||
const Watcher = require('./lib/Watcher'); | ||
try { | ||
const isWatching = argv?.watch || false; | ||
const isServing = argv?.serve || false; | ||
const watchEvents = ['add', 'change', 'unlink', 'addDir', 'unlinkDir']; | ||
const pathToConfig = [process.cwd(), argv?.dir, 'fascio.config.js'].join('/').replace('//', '/'); | ||
const userConfig = require(pathToConfig); | ||
userConfig(isWatching); | ||
userConfig({ isWatching, changedFile: null, isFirstPass: true }); | ||
if (isWatching) { | ||
let dir = `${getDirFromPath(pathToConfig)}/src/**/*`; // TODO: Make this configurable | ||
const watcher = chokidar.watch(dir, { | ||
persistent: true, | ||
}); | ||
watcher.on('error', (error) => { | ||
console.log(chalk.red(`🔴 Error: ${error}`)); | ||
}); | ||
watcher.on('ready', () => { | ||
console.log(chalk.blue('👀 Watching for changes...')); | ||
watchEvents.forEach((event) => { | ||
watcher.on(event, () => { | ||
userConfig(isWatching); | ||
}); | ||
}); | ||
}); | ||
const watcher = new Watcher({ dir, callback: userConfig, context: { isWatching } }); | ||
} | ||
@@ -40,0 +22,0 @@ } catch (error) { |
@@ -0,1 +1,5 @@ | ||
const yargs = require('yargs/yargs'); | ||
const { hideBin } = require('yargs/helpers'); | ||
const argv = yargs(hideBin(process.argv)).argv; | ||
const compilers = { | ||
@@ -2,0 +6,0 @@ scss: require('./lib/compilers/scss'), |
@@ -11,2 +11,7 @@ const getFilenameFromPath = (path) => { | ||
module.exports = { getFilenameFromPath, getDirFromPath }; | ||
const getExtensionFromFilename = (filename) => { | ||
let extension = filename.lastIndexOf('.'); | ||
return filename.substring(extension + 1); | ||
}; | ||
module.exports = { getFilenameFromPath, getDirFromPath, getExtensionFromFilename }; |
{ | ||
"name": "fascio", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "A simple asset bundler for frontend assets", | ||
@@ -5,0 +5,0 @@ "main": "Fascio.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12320
12
319