feat(euler): offer to create a thoughts document as well
-
This commit is contained in:
parent
9ea7ae03a8
commit
704ca26e2c
2 changed files with 14 additions and 5 deletions
|
@ -2,5 +2,6 @@ const path = require('path');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
resources: path.join(__dirname, 'resources'),
|
resources: path.join(__dirname, 'resources'),
|
||||||
src: path.join(__dirname, 'src')
|
src: path.join(__dirname, 'src'),
|
||||||
|
thoughts: path.join(__dirname, 'thoughts')
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const inquirer = require('inquirer');
|
const inquirer = require('inquirer');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { src } = require('../constants');
|
const { src, thoughts: thoughtsDir } = require('../constants');
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
@ -24,10 +24,16 @@ inquirer
|
||||||
parseInt(input) > 100
|
parseInt(input) > 100
|
||||||
? 'Please make sure you choose a number between 1 and 100!'
|
? 'Please make sure you choose a number between 1 and 100!'
|
||||||
: true
|
: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'thoughts',
|
||||||
|
message: 'Should I generate a thoughts document for you?',
|
||||||
|
type: 'confirm',
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
.then(async ({ problemNumber }) => {
|
.then(async ({ problemNumber, thoughts }) => {
|
||||||
const problemName = problems[problemNumber - 1];
|
const fileName = `${problemNumber} - ${problems[problemNumber - 1]}`;
|
||||||
|
|
||||||
// Fetch the problem data off of projecteuler.net
|
// Fetch the problem data off of projecteuler.net
|
||||||
axios.get(`https://projecteuler.net/problem=${problemNumber}`).then(({ data }) => {
|
axios.get(`https://projecteuler.net/problem=${problemNumber}`).then(({ data }) => {
|
||||||
|
@ -40,12 +46,14 @@ inquirer
|
||||||
.join('\n');
|
.join('\n');
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
path.join(src, `${problemNumber} - ${problemName}.ts`),
|
path.join(src, `${fileName}.ts`),
|
||||||
`${problemContent}
|
`${problemContent}
|
||||||
export = {};
|
export = {};
|
||||||
|
|
||||||
// Output
|
// Output
|
||||||
console.log();`
|
console.log();`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (thoughts) fs.writeFileSync(path.join(thoughtsDir, `${fileName}.md`), '');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue