File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
rocket-chatter-ingestion-server/src/process/prepare Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 11import { readFileSync } from "fs"
2- import { TreeNode } from "./processor/core/treeNode "
2+ import path from "path "
33import { ISourceFile } from "./sourceFile.types"
44
55export class SourceFile implements ISourceFile {
66 private _path : string
7- private _syntaxNodes : Record < string , TreeNode > = { }
7+ private _projectPath : string
88
9- constructor ( path : string ) {
10- this . _path = path . replace ( / \\ / g, "/" )
9+ constructor ( filepath : string ) {
10+ // Normalize file path
11+ this . _path = filepath . replace ( / \\ / g, "/" )
12+
13+ // Get project path
14+ const sourceFileAbsolutePath = path . resolve ( this . _path ) . replace ( / \\ / g, "/" )
15+ const projectPath = sourceFileAbsolutePath . slice (
16+ 0 ,
17+ sourceFileAbsolutePath . indexOf ( this . _path )
18+ )
19+ this . _projectPath = projectPath
1120 }
1221
1322 read ( ) : string {
1423 const content = readFileSync ( this . _path , "utf-8" )
1524 return content
1625 }
1726
27+ getProjectPath ( ) : string {
28+ return this . _projectPath
29+ }
30+
1831 getFullPath ( ) : string {
1932 return this . _path
2033 }
Original file line number Diff line number Diff line change @@ -13,5 +13,7 @@ export enum SourceFileType {
1313
1414export interface ISourceFile {
1515 read ( ) : string
16+
17+ getProjectPath ( ) : string
1618 getFullPath ( ) : string
1719}
You can’t perform that action at this time.
0 commit comments