Skip to content

Commit

Permalink
fix outdir bug
Browse files Browse the repository at this point in the history
  • Loading branch information
claviska committed Jan 26, 2022
1 parent 74cc129 commit 4e95733
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ dist
examples
node_modules
src/react
scripts
scripts
2 changes: 1 addition & 1 deletion scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fs.mkdirSync(outdir, { recursive: true });
try {
execSync(`node scripts/make-metadata.js --outdir "${outdir}"`, { stdio: 'inherit' });
execSync(`node scripts/make-search.js --outdir "${outdir}"`, { stdio: 'inherit' });
execSync(`node scripts/make-react.js`, { stdio: 'inherit' });
execSync(`node scripts/make-react.js --outdir "${outdir}"`, { stdio: 'inherit' });
execSync(`node scripts/make-vscode-data.js --outdir "${outdir}"`, { stdio: 'inherit' });
execSync(`node scripts/make-themes.js --outdir "${outdir}"`, { stdio: 'inherit' });
execSync(`node scripts/make-icons.js --outdir "${outdir}"`, { stdio: 'inherit' });
Expand Down
15 changes: 9 additions & 6 deletions scripts/make-react.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import commandLineArgs from 'command-line-args';
import fs from 'fs';
import path from 'path';
import chalk from 'chalk';
Expand All @@ -7,14 +8,16 @@ import prettier from 'prettier';
import prettierConfig from '../prettier.config.cjs';
import { getAllComponents } from './shared.js';

const outdir = path.join('./src/react');
const { outdir } = commandLineArgs({ name: 'outdir', type: String });

const reactDir = path.join('./src/react');

// Clear build directory
del.sync(outdir);
fs.mkdirSync(outdir, { recursive: true });
del.sync(reactDir);
fs.mkdirSync(reactDir, { recursive: true });

// Fetch component metadata
const metadata = JSON.parse(fs.readFileSync('./dist/custom-elements.json', 'utf8'));
const metadata = JSON.parse(fs.readFileSync(path.join(outdir, 'custom-elements.json'), 'utf8'));

// Wrap components
console.log('Wrapping components for React...');
Expand All @@ -24,7 +27,7 @@ const index = [];

components.map(component => {
const tagWithoutPrefix = component.tagName.replace(/^sl-/, '');
const componentDir = path.join(outdir, tagWithoutPrefix);
const componentDir = path.join(reactDir, tagWithoutPrefix);
const componentFile = path.join(componentDir, 'index.ts');
const importPath = component.modulePath.replace(/^src\//, '').replace(/\.ts$/, '');

Expand Down Expand Up @@ -58,6 +61,6 @@ components.map(component => {
});

// Generate the index file
fs.writeFileSync(path.join(outdir, 'index.ts'), index.join('\n'), 'utf8');
fs.writeFileSync(path.join(reactDir, 'index.ts'), index.join('\n'), 'utf8');

console.log(chalk.cyan(`\nComponents have been wrapped for React! 馃摝\n`));
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"es2020"
],
"declaration": true,
"outDir": "./dist",
"rootDir": ".",
"strict": true,
"strictPropertyInitialization": false,
Expand All @@ -37,4 +36,4 @@
"include": [
"src"
]
}
}

0 comments on commit 4e95733

Please sign in to comment.