-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from fhlavac/guide
Init a contribution guide
- Loading branch information
Showing
6 changed files
with
229 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const fse = require('fs-extra'); | ||
const glob = require('glob'); | ||
const path = require('path'); | ||
|
||
const root = process.cwd(); | ||
|
||
const ENV_AGNOSTIC_ROOT = `${root}/src` | ||
|
||
const sourceFiles = glob.sync(path.resolve(__dirname, './src/*/index.ts')) | ||
|
||
async function generateIndex(files) { | ||
// ensure the dynamic root exists | ||
fse.ensureDirSync(path.resolve(ENV_AGNOSTIC_ROOT)); | ||
|
||
const destFile = `${ENV_AGNOSTIC_ROOT}/index.ts`; | ||
|
||
const stream = fse.createWriteStream(destFile); | ||
stream.once('open', () => { | ||
stream.write('// this file is autogenerated by generate-index.js, modifying it manually will have no effect\n'); | ||
|
||
files.forEach(file => { | ||
const name = file.replace('/index.ts', '').split('/').pop(); | ||
stream.write(`\nexport { default as ${name} } from './${name}';\n`); | ||
stream.write(`export * from './${name}';\n`); | ||
}); | ||
stream.end(); | ||
}); | ||
|
||
return Promise.resolve(); | ||
} | ||
|
||
async function run(files) { | ||
try { | ||
await generateIndex(files); | ||
|
||
} catch (error) { | ||
// eslint-disable-next-line no-console | ||
console.error(error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
run(sourceFiles); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,25 @@ | ||
// this file is autogenerated by generate-index.js, modifying it manually will have no effect | ||
|
||
export { default as Battery } from './Battery'; | ||
export * from './Battery'; | ||
|
||
export { default as DetailsPage } from './DetailsPage'; | ||
export * from './DetailsPage'; | ||
|
||
export { default as DetailsPageHeader } from './DetailsPageHeader'; | ||
export * from './DetailsPageHeader'; | ||
|
||
export { default as ErrorBoundary } from './ErrorBoundary'; | ||
export * from './ErrorBoundary'; | ||
|
||
export { default as ErrorStack } from './ErrorStack'; | ||
export * from './ErrorStack'; | ||
|
||
export { default as ErrorState } from './ErrorState'; | ||
export * from './ErrorState'; | ||
|
||
export { default as HorizontalNav } from './HorizontalNav'; | ||
export * from './HorizontalNav'; | ||
|
||
export { default as NotAuthorized } from './NotAuthorized'; | ||
export * from './NotAuthorized'; |