Skip to content
This repository has been archived by the owner on Jul 16, 2022. It is now read-only.

Commit

Permalink
feat(fractal): Add fractal copy task
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed Nov 6, 2018
1 parent 62129df commit 96a1ff9
Show file tree
Hide file tree
Showing 5 changed files with 224 additions and 59 deletions.
51 changes: 34 additions & 17 deletions packages/cli-plugin-fractal/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable global-require,import/no-dynamic-require */
/* eslint-disable global-require,import/no-dynamic-require,no-case-declarations */
const log = require('fancy-log');
const chalk = require('chalk');
const fractal = require('./src/fractal');
Expand All @@ -7,7 +7,7 @@ module.exports = (api, config) => {
api.registerCommand(
'fractal',
{
usage: '<serve|buid> [options]',
usage: '<serve|buid|copy> [options]',
description: 'Run or build a fractal server',
options: {
'-e, --execute <cmd>': {
Expand All @@ -19,24 +19,41 @@ module.exports = (api, config) => {
async (commander, args) => {
const [mode = 'serve'] = args;

if (mode === 'serve') {
let port;
if (commander.execute) {
port = await fractal.runDevBefore(commander.execute);
}
switch (mode) {
case 'serve':
let port;
if (commander.execute) {
port = await fractal.runDevBefore(commander.execute);
}

await fractal.dev(config, port);
} else {
log(`Starting build fractal...`);
await fractal.build(config);
await fractal.dev(config, port);
break;

if (commander.execute) {
log(`Starting build app '${chalk.cyan(commander.execute)}'...`);
await fractal.runBuildAfter(commander.execute, config);
log(`Finished build'${chalk.cyan(commander.execute)}'`);
}
case 'build':
log(`Starting build fractal...`);
await fractal.build(config);

if (commander.execute) {
log(`Starting build app '${chalk.cyan(commander.execute)}'...`);
await fractal.runBuildAfter(commander.execute, config);
log(`Finished build'${chalk.cyan(commander.execute)}'`);
}

log(`Fractal static HTML build complete in ${config.fractal.outputDir}`);
break;

case 'copy':
if (config.get('fractal').copy) {
log(`Starting copy documentation...`);
await fractal.copy(config);
} else {
log(`No copy tasks has registered in fractal configuration`);
}

break;

log(`Fractal static HTML build complete in ${config.fractal.outputDir}`);
default:
break;
}
}
);
Expand Down
Loading

0 comments on commit 96a1ff9

Please sign in to comment.