Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Commit

Permalink
add "download-data" task
Browse files Browse the repository at this point in the history
  • Loading branch information
callumlocke committed Nov 17, 2015
1 parent a946bc0 commit 3b917d0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
/dist/
/.tmp/
/.sass-cache/
/.env
/data.json
23 changes: 23 additions & 0 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import browserify from 'browserify';
import browserSync from 'browser-sync';
import del from 'del';
import dotenv from 'dotenv';
import fetch from 'node-fetch';
import fs from 'fs';
import gulp from 'gulp';
import igdeploy from 'igdeploy';
import mergeStream from 'merge-stream';
Expand All @@ -12,6 +15,8 @@ import vinylBuffer from 'vinyl-buffer';
import watchify from 'watchify';
const $ = require('auto-plug')('gulp');

dotenv.load();

const AUTOPREFIXER_BROWSERS = [
'ie >= 8',
'ff >= 30',
Expand Down Expand Up @@ -234,3 +239,21 @@ gulp.task('deploy', done => {
console.log(`Deployed to http://ig.ft.com/${DEPLOY_TARGET}/`);
});
});

gulp.task('download-data', () => fetch(`https://bertha.ig.ft.com/republish/publish/gss/${process.env.SPREADSHEET_KEY}/data`)
.then(res => res.json())
.then(spreadsheet => {
const data = {};

for (const word of spreadsheet) {
data[word.slug] = data[word.slug] || [];
data[word.slug].push(word);

if (data[word.slug].length > 1) {
console.log('Multiple definitions for this slug:', word.slug);
}
}

fs.writeFileSync('data.json', JSON.stringify(data, null, 2));
})
);
2 changes: 2 additions & 0 deletions package.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"browserify": "^12.0.1",
"debowerify": "^1.3.1",
"del": "^2.0.2",
"dotenv": "^1.2.0",
"eslint": "^1.9.0",
"eslint-config-xo": "^0.8.0",
"fastclick": "^1.0.6",
Expand All @@ -29,6 +30,7 @@
"gulp-util": "^3.0.7",
"igdeploy": "^0.1.0",
"merge-stream": "^1.0.0",
"node-fetch": "^1.3.3",
"nodemon": "^1.8.1",
"run-sequence": "^1.1.4",
"subdir": "0.0.3",
Expand Down

0 comments on commit 3b917d0

Please sign in to comment.