/**
 * Copyright (c) 2016-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */ import * as File from './file' ; import * as path from 'path' ; function pathWithoutLastSlash ( path ) { const lastIndex = path . length - 1 ; if ( path [ lastIndex ] === '/' ) { return path . slice ( 0 , lastIndex ) ; } else { return path ; } } function extraPath ( pathPassedIn ) { if ( typeof pathPassedIn === 'undefined' ) { return '' ; } else { return pathPassedIn ; } } export function getAbsolutePathFromDirectoryAndRelativePath ( directoryPath , relativePath ) { return File . getAbsoluteFilePath ( pathWithoutLastSlash ( path . join ( File . getAbsolutePathString ( directoryPath ) , extraPath ( relativePath ) ) ) ) ; } export function getAbsolutePathFromDirectoryAndAbsoluteOrRelativePath ( directoryPath , relativePath ) { return File . getAbsoluteFilePath ( pathWithoutLastSlash ( path . resolve ( File . getAbsolutePathString ( directoryPath ) , extraPath ( relativePath ) ) ) ) ; } export function getDirectoryPathFromAbsolutePath ( filePath ) { return File . getAbsoluteFilePath ( path . dirname ( File . getAbsolutePathString ( filePath ) ) ) ; }