Skip to content

Commit

Permalink
fix failing github actions
Browse files Browse the repository at this point in the history
- use readdirSync

tagHandler sometimes receives undefined tag node
and i gues this is because of readdir
  • Loading branch information
Epikem committed Jul 19, 2021
1 parent 1077c56 commit 5e80998
Showing 1 changed file with 36 additions and 39 deletions.
75 changes: 36 additions & 39 deletions scripts/blog-updater/src/handle.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,53 +32,50 @@ fs.mkdirSync(writeDir, {
recursive: true,
});

fs.readdir(IN_DIR, (err, filenames) => {
if(err) {
throw err;
}
const files = fs.readdirSync(IN_DIR);

filenames.forEach(filename => {
let filenameinfo = path.parse(filename);
files.forEach(filename => {
let filenameinfo = path.parse(filename);

if(filenameinfo.ext != '.md') {
console.info('skip file', filename);
return;
}
if(filenameinfo.ext != '.md') {
console.info('skip file', filename);
return;
}

const readFilePath = path.join(IN_DIR, filename);
const file_info = {
// NOTE: USING FILENAME AS DATE, 다른 로그 할때는 변경할것.
date: filenameinfo.name.slice(0,10),
private: filenameinfo.name.slice(-2) == '-p'
};

if(file_info.private){
console.warn('private. skipping', filename);
return;
}
const readFilePath = path.join(IN_DIR, filename);

const file_info = {
// NOTE: USING FILENAME AS DATE, 다른 로그 할때는 변경할것.
date: filenameinfo.name.slice(0,10),
private: filenameinfo.name.slice(-2) == '-p'
};

if(file_info.private){
console.warn('private. skipping', filename);
return;
}

const readFile = fs.readFileSync(readFilePath, {
encoding: 'utf8'
});
const readFile = fs.readFileSync(readFilePath, {
encoding: 'utf8'
});

// PROCESS
const result = processFile(readFile, {
...file_info,
});
// PROCESS
const result = processFile(readFile, {
...file_info,
});

console.info('done', filename);
// console.info('done', filename, 'result DATA: ', result);
console.info('done', filename);
// console.info('done', filename, 'result DATA: ', result);

const writeFilePath = path.join(writeDir, file_info.date + '-' + result.data.title.split(/\s/g).join('-') + '.md');
const writeFilePath = path.join(writeDir, file_info.date + '-' + result.data.title.split(/\s/g).join('-') + '.md');

fs.writeFileSync(writeFilePath, result.runData.toString({
encoding: 'utf-8'
}), {
encoding: 'utf-8'
});
});

fs.writeFileSync(writeFilePath, result.runData.toString({
encoding: 'utf-8'
}), {
encoding: 'utf-8'
});
})
})

// define a unified js process that does:
// 1. parses markdown to tree
Expand Down

0 comments on commit 5e80998

Please sign in to comment.