-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-data.js
More file actions
41 lines (33 loc) · 1.01 KB
/
build-data.js
File metadata and controls
41 lines (33 loc) · 1.01 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* eslint-env node */
/**
* Usage: node build-data.js
*/
const Tabletop = require('tabletop');
const jsonfile = require('jsonfile');
const fs = require('fs');
const path = require('path');
var targetPath = 'public/static-files/';
// Inicialmente eliminar archivos
fs.readdirSync(targetPath).forEach((file) => {
fs.unlinkSync(path.join(targetPath, file));
});
Tabletop.init({
key: fs.readFileSync('public/data-spreadsheet-url', 'utf-8').trim(),
callback: function(sheets) {
Object.keys(sheets).forEach(function(key) {
var file = targetPath + key + '.json';
jsonfile.spaces = 2;
jsonfile.writeFileSync(file, sheets[key].elements);
});
}
});
// Tabletop.init({
// key: fs.readFileSync('public/config-spreadsheet-url', 'utf-8').trim(),
// callback: function(sheets) {
// Object.keys(sheets).forEach(function(key) {
// var file = targetPath + key + '.json';
// jsonfile.spaces = 2;
// jsonfile.writeFileSync(file, sheets[key].elements);
// });
// }
// });