-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): support projectData with relative paths
- Loading branch information
1 parent
d6a8952
commit 9636ec0
Showing
5 changed files
with
82 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,12 @@ | ||
import { getEntryFromCliOrConfig } from './internal/get-entry-from-cli-or-config'; | ||
import { cli } from './cli'; | ||
import { getProjectData, ProjectData } from '../api/get-project-data'; | ||
import { FsPath, toFsPath } from '../file-info/fs-path'; | ||
import { getProjectData } from '../api/get-project-data'; | ||
import getFs from '../fs/getFs'; | ||
|
||
export function exportData(...args: string[]): void { | ||
const fs = getFs(); | ||
const projectInfo = getEntryFromCliOrConfig(args[0]); | ||
const relative = (path: FsPath) => fs.relativeTo(projectInfo.rootDir, path) || '.'; | ||
|
||
const projectData = getProjectData(projectInfo.fileInfo.path); | ||
const data: ProjectData = {}; | ||
|
||
for (const [modulePath, moduleData] of Object.entries(projectData)) { | ||
data[relative(toFsPath(modulePath))] = { | ||
module: relative(toFsPath(moduleData.module)), | ||
tags: moduleData.tags, | ||
imports: moduleData.imports.map((importPath) => relative(toFsPath(importPath))), | ||
}; | ||
} | ||
const entryFile = getEntryFromCliOrConfig(args[0], false); | ||
|
||
const data = getProjectData(entryFile, fs.cwd()); | ||
cli.log(JSON.stringify(data, null, ' ')); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters