当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript fs-extra-p.writeJson函数代码示例

本文整理汇总了TypeScript中fs-extra-p.writeJson函数的典型用法代码示例。如果您正苦于以下问题:TypeScript writeJson函数的具体用法?TypeScript writeJson怎么用?TypeScript writeJson使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了writeJson函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: async

  }, true, async (projectDir) => {
    const file = path.join(projectDir, "package.json")
    const data = await readJson(file)
    data.productName = "Test App"

    return await writeJson(file, data)
  })
开发者ID:TakT,项目名称:electron-builder,代码行数:7,代码来源:BuildTest.ts

示例2: setPackageVersions

async function setPackageVersions(packages: Array<string>, packageData: Array<any>) {
  const versions = await BluebirdPromise.map(packages, it => exec("yarn", ["info", "--json", it, "dist-tags"])
    .then((it: string) => {
      if (it === "") {
        // {"type":"error","data":"Received invalid response from npm."}
        // not yet published to npm
        return "0.0.1"
      }

      try {
        return JSON.parse(it).data
      }
      catch (e) {
        throw new Error(`Cannot parse ${it}: ${e.stack || e}`)
      }
    }))
  for (let i = 0; i < packages.length; i++) {
    const packageName = packages[i]
    const packageJson = packageData[i]
    const versionInfo = versions[i]
    const latestVersion = versionInfo.next || versionInfo.latest
    if (latestVersion == null || packageJson.version == latestVersion || semver.lt(latestVersion, packageJson.version)) {
      continue
    }

    packageJson.version = latestVersion
    console.log(`Set ${packageName} version to ${latestVersion}`)
    await writeJson(path.join(packageDir, packageName, "package.json"), packageJson, {spaces: 2})
  }
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:30,代码来源:setVersions.ts

示例3: setPackageVersions

async function setPackageVersions(packageData: Array<any>) {
  const versions = await getLatestVersions(packageData)
  let publishScript = `#!/usr/bin/env bash
set -e
  
ln -f README.md packages/electron-builder/README.md
`

  for (let i = 0; i < packageData.length; i++) {
    const packageMetadata = packageData[i]
    const packageName = packageMetadata.name
    const versionInfo = versions[i]
    const latestVersion = versionInfo.next || versionInfo.latest
    if (latestVersion == null || packageMetadata.version === latestVersion || semver.lt(latestVersion, packageMetadata.version)) {
      continue
    }

    packageMetadata.version = latestVersion
    console.log(`Set ${packageName} version to ${latestVersion}`)
    await writeJson(path.join(packageDir, packageName, "package.json"), packageMetadata, {spaces: 2})
  }

  for (let i = 0; i < packageData.length; i++) {
    const packageMetadata = packageData[i]
    const versionInfo = versions[i]
    const latestVersion = versionInfo.next || versionInfo.latest
    if (latestVersion != null && semver.gt(packageMetadata.version, latestVersion)) {
      publishScript += `npm publish packages/${packageMetadata.name}\n`
    }
  }

  await writeFile(path.join(rootDir, "__publish.sh"), publishScript)
}
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:33,代码来源:setVersions.ts

示例4: setDepVersions

async function setDepVersions(packages: Array<string>, packageData: Array<any>) {
  const versions = packageData.map(it => it.version)
  for (let i = 0; i < packages.length; i++) {
    const packageName = packages[i]
    const packageJson = packageData[i]
    let changed = false
    for (let depIndex = 0; depIndex < packages.length; depIndex++) {
      const depPackageName = packages[depIndex]
      let oldVersion = packageJson.dependencies == null ? null : packageJson.dependencies[depPackageName]
      if (oldVersion == null) {
        continue
      }

      let range = ""
      if (oldVersion.startsWith("~") || oldVersion.startsWith("^")) {
        range = oldVersion[0]
        oldVersion = oldVersion.substring(1)
      }

      const newVersion = versions[depIndex]
      if (oldVersion == newVersion || newVersion === "0.0.0-semantic-release") {
        console.log(`Skip ${depPackageName} for ${packageName} — version ${newVersion} is actual`)
        continue
      }

      changed = true
      packageJson.dependencies[depPackageName] = range + newVersion
      console.log(`Set ${depPackageName} to ${newVersion} from ${oldVersion} for ${packageName}`)
    }

    if (changed) {
      await writeJson(path.join(packageDir, packageName, "package.json"), packageJson, {spaces: 2})
    }
  }
}
开发者ID:djpereira,项目名称:electron-builder,代码行数:35,代码来源:setVersions.ts

示例5: modifyPackageJson

export async function modifyPackageJson(projectDir: string, task: (data: any) => void, isApp = false): Promise<any> {
  const file = isApp ? path.join(projectDir, "app", "package.json") : path.join(projectDir, "package.json")
  const data = await readJson(file)
  task(data)
  // because copied as hard link
  await unlink(file)
  return await writeJson(file, data)
}
开发者ID:electron-userland,项目名称:electron-builder,代码行数:8,代码来源:packTester.ts

示例6: modifyPackageJson

export async function modifyPackageJson(projectDir: string, task: (data: any) => void, isApp: boolean = false): Promise<any> {
  const file = isApp ? path.join(projectDir, "app", "package.json") : path.join(projectDir, "package.json")
  const data = await readJson(file)
  task(data)
  return await writeJson(file, data)
}
开发者ID:GabeIsman,项目名称:electron-builder,代码行数:6,代码来源:packTester.ts

示例7: modifyPackageJson

export async function modifyPackageJson(projectDir: string, task: (data: any) => void): Promise<any> {
  const file = path.join(projectDir, "package.json")
  const data = await readJson(file)
  task(data)
  return await writeJson(file, data)
}
开发者ID:EvgeneOskin,项目名称:electron-builder,代码行数:6,代码来源:packTester.ts


注:本文中的fs-extra-p.writeJson函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。