alsdkjasdlkja
alsdkjasdlkja

Reputation: 1298

Grunt read/write files. Race Condition?

I am wiring up an automated release script for my application with several grunt tasks. Basically, I use

grunt.file.readJSON('package.son', {encoding: 'utf8'});

... to extract the version and increment it, and then I use

fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2), 'utf8');

to write it back. Straight forward.

Another task has to tag the git-commit with the new, incremented, version number and reads the file again. At this point the task still reads the old version. (if I take a look into the file manually later then there is the new version, so increment and write works)

Whats going wrong here? Is that a race condition or are grunt tasks executed asynchronously somehow?

Upvotes: 1

Views: 118

Answers (0)

Related Questions