Skip to content

Commit

Permalink
move selected task to template details
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Mar 20, 2023
1 parent b8e2259 commit 9ec3955
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
7 changes: 3 additions & 4 deletions scripts/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const extraAddons = ['a11y', 'storysource'];
export type Path = string;
export type TemplateDetails = {
key: TemplateKey;
selectedTask: TaskKey;
template: Template;
codeDir: Path;
sandboxDir: Path;
Expand Down Expand Up @@ -327,18 +328,16 @@ async function run() {

const { task: taskKey, startFrom, junit, ...optionValues } = allOptionValues;

// In case other tasks need to know
process.env.SELECTED_TASK = taskKey;

const finalTask = tasks[taskKey];
const { template: templateKey } = optionValues;
const template = TEMPLATES[templateKey];

const templateSandboxDir = templateKey && join(sandboxDir, templateKey.replace('/', '-'));
const details = {
const details: TemplateDetails = {
key: templateKey,
template,
codeDir,
selectedTask: taskKey,
sandboxDir: templateSandboxDir,
builtSandboxDir: templateKey && join(templateSandboxDir, 'storybook-static'),
junitFilename: junit && getJunitFilename(taskKey),
Expand Down
6 changes: 2 additions & 4 deletions scripts/tasks/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ export const dev: Task = {
async ready() {
return (await detectFreePort(PORT)) !== PORT;
},
async run({ sandboxDir, codeDir }, { dryRun, debug }) {
async run({ sandboxDir, codeDir, selectedTask }, { dryRun, debug }) {
const controller = new AbortController();
const devCommand = `yarn storybook --port ${PORT}${
process.env.SELECTED_TASK === 'dev' ? '' : ' --ci'
}`;
const devCommand = `yarn storybook --port ${PORT}${selectedTask === 'dev' ? '' : ' --ci'}`;

exec(
devCommand,
Expand Down

0 comments on commit 9ec3955

Please sign in to comment.