@yarnpkg/core 如何从一个 path 创建一个 Project 实例?

目前吾辈正在写一个 yarn2 的插件,想知道需要测试一些需要 Project/Workspace 参数的函数要怎么做?

function createProjectByPath(dir: string) {
  // ???
}
阅读 1.4k
1 个回答

官方给出了解决方案

const dir = npath.toPortablePath(path.resolve(''))
const configuration = await Configuration.create(dir, dir)
const project = (await Project.find(configuration, dir)).project
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进