all files / src/ syncBackend.js

0% Statements 0/16
0% Branches 0/4
0% Functions 0/3
0% Lines 0/16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26                                                   
/* eslint no-console: 0 */
import fs from 'fs';
import path from 'path';
import { controls } from './explore/controls';
 
function exportFile(fileLocation, content) {
  fs.writeFile(fileLocation, content, function (err) {
    if (err) {
      console.log(`File ${fileLocation} was not saved... :(`);
    } else {
      console.log(`File ${fileLocation} was saved!`);
    }
  });
}
 
function main() {
  const APP_DIR = path.resolve(__dirname, './');
  const dir = APP_DIR + '/../dist/';
  if (!fs.existsSync(dir)) {
    fs.mkdirSync(dir);
  }
  const blob = { controls };
  exportFile(APP_DIR + '/../backendSync.json', JSON.stringify(blob, null, 2));
}
main();