Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions bin/onedrive
Original file line number Diff line number Diff line change
Expand Up @@ -665,9 +665,22 @@ async function cat(args) {
function commandName() {
const argv1 = process.argv[1] || 'onedrive-cli'
const rel = Path.relative(process.cwd(), argv1)
return rel && !rel.startsWith('..') && !Path.isAbsolute(rel)
? rel
: Path.basename(argv1)
const parts = rel.split(Path.sep)
// Running from a directory *above* us yields a long relative path that
// reads like a mangled absolute one -- from '/' this file becomes
// 'Users/me/dev/onedrive-cli/bin/onedrive', which is neither obviously
// runnable nor something to hand to the landing page. Keep at most one
// leading folder, and fall back to the basename beyond that.
if (
!rel ||
parts.length > 2 ||
rel.startsWith('..') ||
Path.isAbsolute(rel)
) {
return Path.basename(argv1)
}
// A bare name is only runnable as './name'; with a folder it already is.
return parts.length === 1 ? '.' + Path.sep + rel : rel
}

function buildLoginUrl(readonly, state) {
Expand Down