Skip to content

Commit

Permalink
Merge pull request #2 from dzbo/1_improved_file_compare
Browse files Browse the repository at this point in the history
[FEATURE] Improve file comparing
  • Loading branch information
dzbo authored Nov 30, 2017
2 parents a07f700 + 01ec100 commit d7006fc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions dist/yata.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/yata.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/yata.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ module.exports = {
const filePath = path.join(process.cwd(), `${this.outputPath}/${fileName}`);
const url = `${this.apiHost}/api/v1/project/${this.project}/${locale}/${this.format}?apiToken=${this.token}&root=${this.root}`;

let fileSize = 0;
let bufferFile;

// if file exist we grab it's size
if (fs.existsSync(filePath)) {
fileSize = fs.statSync(filePath).size;
bufferFile = fs.readFileSync(filePath);
}

// we start stream
Expand All @@ -99,9 +99,9 @@ module.exports = {

response.pipe(file);
file.on('finish', () => {
const newFileSize = fs.statSync(filePath).size;
const newBufferFile = fs.readFileSync(filePath);

if (newFileSize === fileSize) {
if (bufferFile.equals(newBufferFile)) {
log('yellow', `Generating "${locale}" translation. Skipped.`);
} else {
log('green', `Generating "${locale}" translation. Done.`);
Expand Down

0 comments on commit d7006fc

Please sign in to comment.