Skip to content

Commit

Permalink
feat: add example command and update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbarion committed Mar 26, 2024
1 parent 2a93359 commit c06df5b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Simply add these things to your **package.json**. All scripts (a.k.a., commands)
| `upload` | Upload files to gh-pages branch |
| `version` | Output the version of `@pixi/extension-scripts` |
| `watch` | Watch the code in development mode, updates on changes |
| `example` | Copy `dist` folder with the files generated on build step into `examples` folder and start http-server |

### Chaining

Expand Down
22 changes: 22 additions & 0 deletions lib/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ const Command = {
Upload: 'upload',
Version: 'version',
Watch: 'watch',
Example: "example",
};

/** Workflow tasks */
Expand Down Expand Up @@ -319,6 +320,27 @@ const runCommand = async (command, additionalArgs) =>
break;
}
case Command.Watch: bundle('-w'); break;
case Command.Example:
/**
* Copy the dist folder to the examples folder, so the files generated on build can be used on the examples.
* As this will be run on Plugin projects, the path reference will work as expected.
*/
await promises.cp(
"./dist",
"./examples/dist",
{ recursive: true },
(err) => {
if (err) {
console.error(err);
}
}
);

/**
* Start a local server to serve the examples
*/
await spawn("http-server", [extensionConfig.serve]);
break;
default: {
// eslint-disable-next-line no-console
console.error(chalk.red(`${prefix} Error: Unknown command "${command}". `
Expand Down

0 comments on commit c06df5b

Please sign in to comment.