How to use the touchSync function from touch

Find comprehensive JavaScript touch.touchSync code examples handpicked from public code repositorys.

touch.touchSync is a Node.js function that updates the timestamp for a file or creates a new empty file if it doesn't exist.

768
769
770
771
772
773
774
775
776
777
  if (!exists) {
    if (state.opts.outputDir) {
      mkdirp.sync(nodePath.dirname(cssFileOnDisk));
    }

    touch.touchSync(cssFileOnDisk);
  }

  fs.writeFileSync(cssFileOnDisk, toWrite);
}
fork icon0
star icon0
watch icon1

+ 2 other calls in file

How does touch.touchSync work?

touch.touchSync is a function in the Node.js touch package that updates the access and modification time of a file or creates a new file if it does not exist, synchronously without a callback, based on the provided path and options.

Ai Example

1
2
3
const touch = require("touch");

touch.touchSync("example.txt");

If example.txt already exists, the method will update its access and modification times to the current time.