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


TypeScript fs-extra.writeFile函数代码示例

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


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

示例1: it

    it('can discard modified change cleanly', async () => {
      const path = await setupFixtureRepository('repository-with-HEAD-file')
      const repo = new Repository(path, 1, null, false)
      const gitStore = new GitStore(repo, shell)

      const file = 'README.md'
      const filePath = Path.join(repo.path, file)

      await FSE.writeFile(filePath, 'SOME WORDS GO HERE\n')

      let status = await getStatusOrThrow(repo!)
      let files = status.workingDirectory.files
      expect(files.length).to.equal(1)

      await gitStore.discardChanges([files[0]])

      status = await getStatusOrThrow(repo)
      files = status.workingDirectory.files
      expect(files.length).to.equal(0)
    })
开发者ID:soslanashkhotov,项目名称:desktop,代码行数:20,代码来源:git-store-test.ts

示例2: main

// Main function
async function main(version: string, milestone: string): Promise<void> {
    if (!milestone) {
        throw new Error('You should input \'milestone\'.');
    }

    const prs = await getAllPullRequestsForMilestone(milestone);

    // Read changelogs and update
    const CHANGELOGS_JSON_FILE = path.resolve(__dirname, '../changelogs.json');
    let changelogs: ChangelogOfVersion[] = await readJson(CHANGELOGS_JSON_FILE, { throws: true });

    changelogs = updateChangelogs(changelogs, version, prs);

    await writeJson(CHANGELOGS_JSON_FILE, changelogs);

    // Write changelog markdown.
    const CHANGELOG_MARKDOWN_FILE = path.resolve(__dirname, '../CHANGELOG.md');
    const content = getMarkdownFromChangelogs(changelogs);

    await writeFile(CHANGELOG_MARKDOWN_FILE, content);
}
开发者ID:suiruiw,项目名称:geeks-diary,代码行数:22,代码来源:changelog.ts

示例3: it

    it('commit does not strip commentary by default', async () => {
      await FSE.writeFile(
        path.join(repository!.path, 'README.md'),
        'Hi world\n'
      )

      const status = await getStatusOrThrow(repository!)
      const files = status.workingDirectory.files
      expect(files.length).to.equal(1)

      const message = `Special commit

# this is a comment`

      await createCommit(repository!, message, files)

      const commit = await getCommit(repository!, 'HEAD')
      expect(commit).to.not.be.null
      expect(commit!.summary).to.equal('Special commit')
      expect(commit!.body).to.equal('# this is a comment\n')
    })
开发者ID:soslanashkhotov,项目名称:desktop,代码行数:21,代码来源:commit-test.ts

示例4: it

  it('can ignore a file in a repository', async () => {
    const repo = await setupEmptyRepository()
    const sut = new RepositorySettingsStore(repo)
    const path = repo.path

    // Ignore txt files
    await sut.saveGitIgnore('*.txt\n')
    await GitProcess.exec(['add', '.gitignore'], path)
    await GitProcess.exec(['commit', '-m', 'create the ignore file'], path)

    // Create a txt file
    const file = Path.join(repo.path, 'a.txt')

    await FSE.writeFile(file, 'thrvbnmerkl;,iuw')

    // Check status of repo
    const status = await getStatusOrThrow(repo)
    const files = status.workingDirectory.files

    expect(files.length).to.equal(0)
  })
开发者ID:soslanashkhotov,项目名称:desktop,代码行数:21,代码来源:repository-settings-store-test.ts

示例5: getFileOutputInfo

    saveFileContent: (path, content, callback) => {

        // Make content optional with an empty string as a default
        if (typeof content === "function") {
            callback = content;
            content  = "";
        }

        // Open file for writing. Fails if file doesn't exist
        fs.writeFile(path, content, {flag: "w"}, (err) => {
            if (err) return callback(err);

            // If we've written successfully to the file, return the info object
            getFileOutputInfo(path, (err, info) => {
                if (err) return callback(err);

                callback(null, info);
            });
        });

    },
开发者ID:hmenager,项目名称:composer,代码行数:21,代码来源:fs.controller.ts

示例6: it

 it('should redownload when force=true', async () => {
   const zipPath = await download('2.0.9', {
     cacheRoot,
     force: true,
   });
   const hash = crypto
     .createHash('sha256')
     .update(await fs.readFile(zipPath))
     .digest('hex');
   await fs.writeFile(zipPath, 'bad content');
   const zipPath2 = await download('2.0.9', {
     cacheRoot,
     force: true,
   });
   expect(zipPath).toEqual(zipPath2);
   const hash2 = crypto
     .createHash('sha256')
     .update(await fs.readFile(zipPath2))
     .digest('hex');
   expect(hash).toEqual(hash2);
 });
开发者ID:electron-userland,项目名称:electron-download,代码行数:21,代码来源:index.spec.ts

示例7: function

export default async function() {
  const corePkg = require(path.join(process.cwd(), 'package.json'));
  for (const w of await getWorkspaces()) {
    let pkg = { ...pkgDefault, ...w.config };
    pkg = Object.keys(pkg)
      .sort()
      .reduce((prev, next) => {
        prev[next] = pkg[next];
        return prev;
      }, {}) as Pkg;

    // Copy these from the main package.json.
    ['author', 'bugs', 'homepage', 'keywords', 'license', 'repository'].forEach(
      key => {
        pkg[key] = corePkg[key];
      }
    );

    // If using TypeScript, we automate the output, otherwise just use the source.
    if (pkg.source) {
      if (pkg.source.match(regexTsSuffix)) {
        pkg.browser = 'module/index.js';
        pkg.esnext = 'esnext/index.js';
        pkg.main = 'main/index.js';
        pkg.module = 'module/index.js';
      } else {
        delete pkg.browser;
        delete pkg.esnext;
        delete pkg.module;
        pkg.main = pkg.source;
      }
    }

    await fs.writeFile(
      path.join(w.dir, 'package.json'),
      JSON.stringify(pkg, null, 2)
    );
  }
}
开发者ID:skatejs,项目名称:skatejs,代码行数:39,代码来源:sync-files.ts

示例8: it

    it('commits the given files', async () => {
      await FSE.writeFile(
        path.join(repository!.path, 'README.md'),
        'Hi world\n'
      )

      let status = await getStatusOrThrow(repository!)
      let files = status.workingDirectory.files
      expect(files.length).toEqual(1)

      const sha = await createCommit(repository!, 'Special commit', files)
      expect(sha).toHaveLength(7)

      status = await getStatusOrThrow(repository!)
      files = status.workingDirectory.files
      expect(files.length).toEqual(0)

      const commits = await getCommits(repository!, 'HEAD', 100)
      expect(commits.length).toEqual(6)
      expect(commits[0].summary).toEqual('Special commit')
      expect(commits[0].sha.substring(0, 7)).toEqual(sha)
    })
开发者ID:ghmoore,项目名称:desktop,代码行数:22,代码来源:commit-test.ts

示例9: fixDependencies

async function fixDependencies() {
  const packagePath = path.join(process.cwd(), 'package.json')
  const packageJson = require(packagePath)

  if (typeof packageJson.dependencies === 'undefined') {
    console.error(chalk.red('Missing dependencies in package.json'))
    process.exit(1)
  }

  const packageVersion = packageJson.dependencies['tux-scripts']

  if (typeof packageVersion === 'undefined') {
    console.error(chalk.red(`Unable to find tux-scripts in package.json`))
    process.exit(1)
  }

  packageJson.devDependencies = packageJson.devDependencies || {}
  packageJson.devDependencies['tux-scripts'] = packageVersion
  delete packageJson.dependencies['tux-scripts']

  await fs.writeFile(packagePath, JSON.stringify(packageJson, null, 2))
}
开发者ID:aranja,项目名称:tux,代码行数:22,代码来源:new.ts


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