How to use the mz/fs.readFile function in mz

To help you get started, we’ve selected a few mz examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pedromsilvapt / unicast / src / Tools / LoadArtwork.ts View on Github external
async run ( options : LoadArtworkOptions ) {
        const repository = this.server.repositories.get( options.repository );

        for ( let record of JSON.parse( await fs.readFile( options.input, 'utf8' ) ) ) {
            this.log( record.id, record.title, record.art.poster );
            
            const match = await this.server.media.get( options.kind, record.id );

            for ( let property of options.properties ) {
                if ( match.art[ property ] != record.art[ property ] ) {
                    repository.setPreferredMediaArt( match.kind, match.id, property, record.art[ property ] );

                    match.art[ property ] = record.art[ property ];
                }
            }

            // if ( match.art.poster != show.art.poster ) {
            //     repository.setPreferredMediaArt( match.kind, match.id, 'poster', show.art.poster );
            // }
github musically-ut / appreciate / index.js View on Github external
function readAuthToken(authFile) {
    if (!authFile) {
        authFile = expandHomeDir('~/.appreciate');
    }

    return fs.readFile(authFile).then(tokenBuffer => {
        // Convert the buffer to string
        return tokenBuffer.toString('utf8').trim();
    });
}
github commercetools / nodejs / integration-tests / cli / inventories-exporter.it.js View on Github external
it('should export inventories to file as csv', async () => {
      const csvFilePath = tmp.fileSync().name
      const [stdout, stderr] = await exec(
        `${binPath} -p ${projectKey} -o ${csvFilePath} -f csv`
      )
      expect(stdout && stderr).toBeFalsy()
      const data = await fs.readFile(csvFilePath, { encoding: 'utf8' })
      const expectedData = `12345,20,inventory-custom-type,integration tests!! arrgggh,${new Date().getFullYear()}`
      expect(data).toContain(expectedData)
    })
  })
github hybridables / always-done / test / promises.js View on Github external
function failReadFile () {
  return fs.readFile('foo-bar')
}
github rpl / create-webextension / index.js View on Github external
function getProjectCreatedMessage(projectPath) {
  return fs.readFile(path.join(__dirname, "assets", "webextension-logo.ascii"))
           .then(asciiLogo => {
             const PROJECT_CREATED_MSG = `\n
Congratulations!!! A new WebExtension has been created at:

  ${chalk.bold(chalk.green(projectPath))}`;

             return `${asciiLogo} ${PROJECT_CREATED_MSG} ${MORE_INFO_MSG}`;
           });
}
github umijs / vscode-extension-umi-pro / src / services / parser / modelReferenceParser.ts View on Github external
public async parseFile(filePath: string) {
    const code = await fs.readFile(filePath, 'utf-8');
    const config = this.vscodeService.getConfig(filePath);
    if (!config) {
      return [];
    }
    const ast = babelParser.parse(code, config.parserOptions);
    const result: ModelReference[] = [];
    traverse(ast, {
      enter(path) {
        const { node } = path;
        if (!isCallExpression(node)) {
          return;
        }
        const { callee } = node;
        if (!isIdentifier(callee) || node.arguments.length !== 1) {
          return;
        }
github CMSgov / design-system / tools / gulp / stats / stats.js View on Github external
function createSpecificityGraph(stats, filename) {
  const tmpPath = path.resolve(__dirname, '../../../tmp');
  const outputPath = path.resolve(tmpPath, `specificity.${filename}.html`);
  const specificity = stats.selectors.getSpecificityGraph();
  const selectors = stats.selectors.values;
  const chartRows = specificity.map((val, index) => {
    const tooltip = `<strong>${val}</strong><br><code>${selectors[index]}</code>`;
    return [index, val, tooltip];
  });

  return fs
    .readFile(path.resolve(__dirname, 'chart-template.html'), 'utf8')
    .then(body =&gt; body.replace(/{{ROW_DATA}}/, JSON.stringify(chartRows)))
    .then(body =&gt; {
      if (!fs.existsSync(tmpPath)) {
        fs.mkdir(tmpPath).then(() =&gt; body);
      }

      return body;
    })
    .then(body =&gt; fs.writeFile(outputPath, body, 'utf8'))
    .then(() =&gt; {
      dutil.logMessage('📈 ', `Specificity graph created: ${outputPath}`);
    });
}
github staticdeploy / staticdeploy / storage / src / BundlesClient.ts View on Github external
await concurrentForEach(assets, async asset => {
            const assetContent = await readFile(join(rootPath, asset.path));
            await this.s3Client
                .putObject({
                    Bucket: this.s3Bucket,
                    Body: assetContent,
                    Key: this.getAssetS3Key(id, asset.path)
                })
                .promise();
        });
github silklabs / silk / bsp-gonk / vendor / silk / silk-battery / index.js View on Github external
_readCapacity(): Promise {
    return fs.readFile('/sys/class/power_supply/battery/capacity')
    .then((data) =&gt; Number(data.toString()));
  }
github GoogleChromeLabs / ProgressiveWordPress / build.js View on Github external
async function copy(from, to) {
  const data = await fs.readFile(from);
  const dir = path.dirname(to);
  await mkdirAll(dir);
  await fs.writeFile(to, data);
}