Skip to content

Commit

Permalink
Make sure to create samples directry for package
Browse files Browse the repository at this point in the history
  • Loading branch information
nagix committed May 4, 2021
1 parent b2852ab commit fe84122
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"eslint-plugin-es": "^4.1.0",
"eslint-plugin-html": "^6.1.2",
"eslint-plugin-markdown": "^2.0.1",
"fs-extra": "^10.0.0",
"glob": "^7.1.6",
"replacestream": "^4.0.3",
"rollup": "^2.45.1",
Expand Down
8 changes: 4 additions & 4 deletions scripts/create-samples.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

const glob = require('glob');
const replace = require('replacestream');
const fs = require('fs');
const fs = require('fs-extra');
const path = require('path');

const root = path.resolve(__dirname, '..');
const files = glob.sync('samples/**/*', {cwd: root});

(async() => {
await fs.emptyDir(path.join(root, 'dist', 'samples'));

await Promise.all(files.map((file) => new Promise((resolve, reject) => {
const dest = fs.createWriteStream(path.join(root, 'dist', file));
fs.createReadStream(path.join(root, file))
.pipe(replace(/src="((?:\.\.\/)+)dist\//, 'src="$1'))
.pipe(dest);
dest.on('finish', () => {
resolve();
});
dest.on('finish', () => resolve);
dest.on('error', reject);
})));
})().catch((error) => {
Expand Down

0 comments on commit fe84122

Please sign in to comment.