qetza / replacetokens-task

Azure Pipelines task to replace tokens in files with variables.
MIT License
7 stars 2 forks source link

Is it posible not to change the filedate. #41

Open Anderman opened 1 month ago

Anderman commented 1 month ago

Robo copy sees this as a new file. This also give problems in a webfarm where a small part is deployed to a shared folder

qetza commented 1 month ago

Hi @Anderman, It's the system that is automatically changing the last modified date so I have no way to avoid this. I will review the code to make sure that the file is not written if there is no changes though.

Anderman commented 1 month ago

You can do something like this in your index.js Probably you can make it optional

if (counters.tokens > 0) { // write updated content if tokens where found const { atime, mtime } = await fs.stat(input); await fs.writeFile(output, iconv.encode(result.content, file.encoding, { addBOM: options.addBOM })); await fs.utimes(output, atime, mtime); } else if (input !== output) { // copy original file as binary if not token found await fs.copyFile(input, output); } ``

qetza commented 2 weeks ago

Hi @Anderman, I think for this specific scenario i'll let people do it through scripting outside of the task as the files are modified so it's normal to change the file dates.

You could have a pre script which records the dates of the files and the a post scripts which would reapply the dates.