mirror of
https://github.com/cloudflare/wrangler-action.git
synced 2024-11-22 10:03:24 +01:00
25 lines
585 B
JavaScript
25 lines
585 B
JavaScript
'use strict'
|
|
const path = require('path')
|
|
const isWindows = require('is-windows')
|
|
|
|
module.exports = isWindows() ? winResolve : path.resolve
|
|
|
|
function winResolve (p) {
|
|
if (arguments.length === 0) return path.resolve()
|
|
if (typeof p !== 'string') {
|
|
return path.resolve(p)
|
|
}
|
|
// c: => C:
|
|
if (p[1] === ':') {
|
|
const cc = p[0].charCodeAt()
|
|
if (cc < 65 || cc > 90) {
|
|
p = `${p[0].toUpperCase()}${p.substr(1)}`
|
|
}
|
|
}
|
|
// On Windows path.resolve('C:') returns C:\Users\
|
|
// We resolve C: to C:
|
|
if (p.endsWith(':')) {
|
|
return p
|
|
}
|
|
return path.resolve(p)
|
|
}
|