Esempio n. 1
0
 return bankPromise.then(() => jsonfile.readFile(path.join(__dirname, bankPath))
   .then(bank => lintBank(bank, bankPath, bankName, country, schema))
   .then(bank => jsonfile.writeFile(fullPath, bank, { spaces: 2 }))
   .then(() => {
     helper.success(`banks/${country}/${bankName}`);
   })
   .catch(reject));
Esempio n. 2
0
  countries.reduce((countryPromise, country) => {
    const banks = fs.readdirSync(
      path.join(__dirname, `banks/${country}`)
    ).filter(file => /\.json$/.test(file));

    return countryPromise.then(() => banks.reduce((bankPromise, bankName) => {
      const bankPath = `banks/${country}/${bankName}`;
      const fullPath = path.join(__dirname, bankPath);
      return bankPromise.then(() => jsonfile.readFile(path.join(__dirname, bankPath))
        .then(bank => lintBank(bank, bankPath, bankName, country, schema))
        .then(bank => jsonfile.writeFile(fullPath, bank, { spaces: 2 }))
        .then(() => {
          helper.success(`banks/${country}/${bankName}`);
        })
        .catch(reject));
    }, Promise.resolve()));
  }, Promise.resolve());

  if (/\.json/.test(files.join())) {
    reject(new Error('JSON must not be placed straight in banks folder'));
  }
});

jsonfile.readFile(path.join(__dirname, 'schema.json')).then((schema) => {
  fs.readdir(path.join(__dirname, 'banks')).then(files => lint(files, schema)).catch((err) => {
    helper.error(err);
    process.exit(1);
  });
}).catch(helper.error);