Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

Commit

Permalink
fix: fixed doc urls when only ts files are available
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jun 20, 2018
1 parent 6311e15 commit 01945c3
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/commands/readme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,24 @@ USAGE
let commandsDir = plugin.pjson.oclif.commands
if (!commandsDir) return
let p = path.join(plugin.root, commandsDir, ...c.id.split(':'))
if (fs.pathExistsSync(path.join(p, 'index.js'))) p = path.join(p, 'index.js')
else p = p + '.js'
if (!fs.pathExistsSync(p)) return
p = p.replace(plugin.root + '/', '')
if (fs.pathExistsSync(path.join(p, 'index.js'))) {
p = path.join(p, 'index.js')
} else if (fs.pathExistsSync(p + '.js')) {
p = p + '.js'
} else if (plugin.pjson.devDependencies.typescript) {
// check if non-compiled scripts are available
let base = p.replace(plugin.root + path.sep, '')
p = path.join(plugin.root, base.replace(new RegExp('^lib' + path.sep), 'src' + path.sep))
if (fs.pathExistsSync(path.join(p, 'index.ts'))) {
p = path.join(p, 'index.ts')
} else if (fs.pathExistsSync(p + '.ts')) {
p = p + '.ts'
} else return

} else return
p = p.replace(plugin.root + path.sep, '')
if (plugin.pjson.devDependencies.typescript) {
p = p.replace(/^lib\//, 'src/')
p = p.replace(new RegExp('^lib' + path.sep), 'src' + path.sep)
p = p.replace(/\.js$/, '.ts')
}
return p
Expand Down

0 comments on commit 01945c3

Please sign in to comment.