mirror of
https://github.com/misenhower/splatoon2.ink.git
synced 2026-04-25 07:52:38 -05:00
Move last tweet times to the storage directory
This commit is contained in:
parent
66686eca2f
commit
a39a6f8354
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -3,7 +3,5 @@ node_modules
|
|||
docker-compose.override.yml
|
||||
public/*
|
||||
logs
|
||||
manual-festivals.json
|
||||
manual-salmonrun.json
|
||||
twitter-lastTweetTimes.json
|
||||
test-screenshot-*
|
||||
/storage
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { postMediaTweet } = require('./client');
|
||||
const { getTopOfCurrentHour, readJson } = require('../utilities');
|
||||
const { getTopOfCurrentHour, readJson, writeJson } = require('../utilities');
|
||||
|
||||
const lastTweetTimesPath = path.resolve('twitter-lastTweetTimes.json');
|
||||
const lastTweetTimesPath = path.resolve('storage/twitter-lastTweetTimes.json');
|
||||
|
||||
class TwitterPostBase {
|
||||
maybePostTweet() {
|
||||
|
|
@ -84,7 +84,7 @@ class TwitterPostBase {
|
|||
|
||||
lastTweetTimes[key] = time;
|
||||
|
||||
fs.writeFileSync(lastTweetTimesPath, JSON.stringify(lastTweetTimes));
|
||||
writeJson(lastTweetTimesPath, lastTweetTimes);
|
||||
}
|
||||
|
||||
shouldPostForCurrentTime() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const mkdirp = require('mkdirp');
|
||||
|
||||
const dataPath = path.resolve('public/data');
|
||||
|
||||
|
|
@ -16,6 +17,12 @@ function readJson(filename) {
|
|||
}
|
||||
module.exports.readJson = readJson;
|
||||
|
||||
function writeJson(filename, data) {
|
||||
mkdirp(path.dirname(filename));
|
||||
fs.writeFileSync(filename, JSON.stringify(data));
|
||||
}
|
||||
module.exports.writeJson = writeJson;
|
||||
|
||||
function readData(filename) {
|
||||
return readJson(`${dataPath}/${filename}`);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user