Replace path with universal paths
This commit is contained in:
@@ -10,6 +10,7 @@ import {Collection} from '../collection/Collection.ts'
|
||||
import {path} from '../external/std.ts'
|
||||
import Scaffolding from '../unit/Scaffolding.ts'
|
||||
import {Container} from '../../../di/src/Container.ts'
|
||||
import {PathLike} from "../support/UniversalPath.ts";
|
||||
|
||||
/**
|
||||
* Central class for Daton applications.
|
||||
@@ -115,7 +116,7 @@ export default class Application {
|
||||
* @type string
|
||||
*/
|
||||
get root() {
|
||||
return this.injector.make(Scaffolding).base_dir
|
||||
return this.injector.make(Scaffolding).base_path
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,17 +124,7 @@ export default class Application {
|
||||
* @type string
|
||||
*/
|
||||
get app_root() {
|
||||
let base_dir = this.injector.make(Scaffolding).base_dir
|
||||
if ( base_dir.startsWith('file://') ) {
|
||||
base_dir = base_dir.slice(7)
|
||||
}
|
||||
|
||||
const resolved = path.resolve(base_dir, 'app')
|
||||
if ( resolved.startsWith('/') ) {
|
||||
return `file://${resolved}`
|
||||
} else {
|
||||
return resolved
|
||||
}
|
||||
return this.root.concat('app')
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,18 +132,8 @@ export default class Application {
|
||||
* @param {...string} parts
|
||||
* @return string
|
||||
*/
|
||||
path(...parts: string[]) {
|
||||
let root = this.root
|
||||
if ( root.startsWith('file://') ) {
|
||||
root = root.slice(7)
|
||||
}
|
||||
|
||||
const resolved = path.resolve(root, ...parts)
|
||||
if ( resolved.startsWith('/') ) {
|
||||
return `file://${resolved}`
|
||||
} else {
|
||||
return resolved
|
||||
}
|
||||
path(...parts: PathLike[]) {
|
||||
return this.root.concat(...parts)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,17 +141,7 @@ export default class Application {
|
||||
* @param {...string} parts
|
||||
* @return string
|
||||
*/
|
||||
app_path(...parts: string[]) {
|
||||
let app_root = this.app_root
|
||||
if ( app_root.startsWith('file://') ) {
|
||||
app_root = app_root.slice(7)
|
||||
}
|
||||
|
||||
const resolved = path.resolve(app_root, ...parts)
|
||||
if ( resolved.startsWith('/') ) {
|
||||
return `file://${resolved}`
|
||||
} else {
|
||||
return resolved
|
||||
}
|
||||
app_path(...parts: PathLike[]) {
|
||||
return this.app_root.concat(...parts)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user