Skip to content

Commit

Permalink
chore(examples): update grid example for deploy (#7577)
Browse files Browse the repository at this point in the history
* chore(examples): debug example script

* chore(examples): debug example script

* chore(examples): debug example script

* chore(examples): update to fail on subprocess exit code 1

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
joshblack and kodiakhq[bot] authored Jan 19, 2021
1 parent ac31323 commit 4699dc0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/grid/examples/preview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.0.0",
"license": "Apache-2.0",
"scripts": {
"build": "export PATH_PREFIX=\"/grid/examples/preview\" && parcel build -d build --public-url $PATH_PREFIX index.html",
"build": "parcel build -d build --public-url \"/grid/examples/preview\" index.html",
"develop": "parcel index.html --no-cache"
},
"devDependencies": {
Expand Down
20 changes: 16 additions & 4 deletions tasks/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const IGNORE_EXAMPLE_DIRS = new Set([
'styled-components',
'vue-cli',
'storybook',
'sass-modules',
]);

/**
Expand Down Expand Up @@ -91,7 +92,7 @@ async function main() {
packagesWithExamples.map(async (pkg) => {
reporter.info(`Building examples in package \`${pkg.name}\``);

const { examples, filepath, name } = pkg;
const { examples, name } = pkg;
const packageDir = path.join(BUILD_DIR, name, 'examples');

await fs.ensureDir(packageDir);
Expand All @@ -110,14 +111,25 @@ async function main() {
await fs.ensureDir(exampleDir);

if (packageJson.scripts.build) {
spawn.sync('yarn', ['install'], {
const installResult = spawn.sync('yarn', ['install'], {
stdio: 'ignore',
cwd: example.filepath,
});
spawn.sync('yarn', ['build'], {
if (installResult.status !== 0) {
throw new Error(
`Error installing dependencies for ${pkg.name}:${example.name}`
);
}

const buildResult = spawn.sync('yarn', ['build'], {
stdio: 'ignore',
cwd: example.filepath,
});
if (buildResult.status !== 0) {
throw new Error(
`Error building example ${example.name} for ${pkg.name}`
);
}
}

if (await fs.pathExists(exampleBuildDir)) {
Expand All @@ -126,7 +138,7 @@ async function main() {
}

await fs.copy(example.filepath, exampleDir, {
filter(src, dest) {
filter(src) {
const relativePath = path.relative(example.filepath, src);
if (relativePath.includes('node_modules')) {
return false;
Expand Down

0 comments on commit 4699dc0

Please sign in to comment.