Skip to content

Commit

Permalink
docs: reformat inline docs
Browse files Browse the repository at this point in the history
  • Loading branch information
osdevisnot committed Aug 11, 2020
1 parent b07bb60 commit ddd9065
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
node_modules
dist/
dist
coverage
.idea
*.log
yarn.lock
package-lock.json
3 changes: 1 addition & 2 deletions src/init-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ const createTsConfig = () => `{
}
}`

const createReadme = (name) => `# ${name}
`
const createReadme = (name) => `# ${name}`

export const getDefaults = (pkg, template) =>
[
Expand Down
17 changes: 5 additions & 12 deletions src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,13 @@ const writePackage = async (template, { user, email }) => {
}

/**
* Write boilerplate scripts and common files such as LICENSE and .gitignore to
* user's directories.
* Write boilerplate scripts and common files such as LICENSE and .gitignore to user's directories.
*/
const writeFiles = async (pkg, template) => {
// An array of objects each having `file`, `content`, & optionally
// `extensions` properties
// An array of objects each having `file`, `content`, & optionally `extensions` properties
const files = [...getDefaults(pkg, template), ...getTemplates(pkg, template)]

// Write files.
// Only write files that don't already exist.
// Write files, that do not already exist.
for (const { file, content, extensions } of files) {
let existing = false
// If there's a range of possible extensions, check them all.
Expand All @@ -102,17 +99,13 @@ const writeFiles = async (pkg, template) => {
* The main function exported by this module.
*/
export const init = async () => {
const template = process.argv[3] || 'js' // js, jsx, ts, tsx
const template = process.argv[3] || 'js'

if (!['js', 'ts', 'jsx', 'tsx'].includes(template)) {
error('Invalid init template. Try one of js, jsx, ts, tsx')
return
}

const pkg = await writePackage(template, gitInfo())
await writeFiles(pkg, template)

if (!process.argv[3]) {
log('\nWant to use typescript with klap?')
info('Initialize your package with `klap init ts`\n')
}
}
3 changes: 1 addition & 2 deletions src/klap.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { dirname, basename } from 'path'
import { rollup, watch } from 'rollup'
import { error, info, log } from './logger'
import { getOptions } from './options'
import { plugins } from './plugins'
import { plugins, dts } from './plugins'
import { exists, read } from './utils'
import dts from 'rollup-plugin-dts'

const defaultInputOptions = { inlineDynamicImports: true }
const defaultOutputOptions = { esModule: false, strict: false, freeze: false }
Expand Down
4 changes: 3 additions & 1 deletion src/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import replace from '@rollup/plugin-replace'
import nodeGlobals from 'rollup-plugin-node-globals'
import babel from '@rollup/plugin-babel'

import dts from 'rollup-plugin-dts'

import { terser } from './packages/terser'
import { sizeme } from './packages/sizeme'
import { servor } from './packages/servor'
Expand Down Expand Up @@ -43,4 +45,4 @@ const plugins = (command, pkg, options) => {
].filter(Boolean)
}

export { plugins }
export { plugins, dts }

0 comments on commit ddd9065

Please sign in to comment.