@mhy/config
Version:
> This documentation is not complete. It's in progress and it's a BETA version. Use the tool at your own risk.
60 lines (46 loc) • 1.48 kB
JavaScript
;
var _dist = _interopRequireDefault(require("@mhy/process/dist"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
const CmdStorybookStartCLI = ['node', require.resolve('@storybook/react/bin/index.js')];
const {
start
} = require('../../storybook');
for (const [key, value] of Object.entries(start)) {
if (value !== null) {
CmdStorybookStartCLI.push(`--${key}`);
CmdStorybookStartCLI.push(value);
}
}
class StorybookStart extends _dist.default {
constructor(args) {
const {
args: [defaultAction = 'start'],
flags
} = args;
super(args);
_defineProperty(this, "onStart", ({
name
}) => this.spawn(name, CmdStorybookStartCLI));
_defineProperty(this, "onRestart", async () => {
await this.kill('start');
this.run('start');
});
_defineProperty(this, "actions", [{
name: 'start',
enabled: true,
onRun: this.onStart
}, {
name: 'restart',
label: 'Restart',
shortcut: 'r',
enabled: true,
onRun: this.onRestart
}]);
this.run(defaultAction, {
flags
});
}
}
_defineProperty(StorybookStart, "isEnabled", true);
module.exports.default = () => StorybookStart;