TechnologyAdvice/DevLab

View on GitHub
src/dewindowize.js

Summary

Maintainability
A
0 mins
Test Coverage
const path = require('path')
const process = require('process')

/**
 * Method to convert a Windows path to a form that Docker accepts
 * @param {string} (winPath) path to convert
 * @returns {String} the converted path
 */
module.exports = (winPath) => {
  if (process.platform === 'win32' && path.isAbsolute(winPath)) {
    return ('/' + winPath.replace(':', '').replace(new RegExp('\\\\', 'g'), '/'))
  } else {
    return winPath
  }
}