1 | var fs = require('fs')
|
2 | var filePath = process.argv[2]
|
3 |
|
4 | const handler = function (stat) {
|
5 | if (stat && stat.birthtime.getTime() > 0) {
|
6 | process.exit(0)
|
7 | }
|
8 | }
|
9 |
|
10 | fs.watchFile(filePath, { interval: 100 }, handler)
|
11 | fs.stat(filePath, function (err, stat) { handler(stat) })
|