1
0
Fork 0
mirror of https://github.com/actions/toolkit synced 2025-05-08 16:17:40 +00:00
toolkit/packages/exec/__tests__/scripts/wait-for-file.js
Danny McCormick c5f27c3c1b
Add exec (#10)
* Add exec

* Fix linux tests

* unnecessary dependency

* Dont prefix ExecOptions with I

* Consistency nits

* Respond to feedback

* Add toolrunner explanatory quote

* Format
2019-05-28 15:21:45 -04:00

35 lines
No EOL
609 B
JavaScript

var fs = require('fs');
// get the command line args that use the format someArg=someValue
var args = {};
process.argv.forEach(function (arg) {
var match = arg.match(/^(.+)=(.*)$/);
if (match) {
args[match[1]] = match[2];
}
});
var state = {
file: args.file
};
if (!state.file) {
throw new Error('file is not specified');
}
state.checkFile = function (s) {
try {
fs.statSync(s.file);
}
catch (err) {
if (err.code == 'ENOENT') {
return;
}
throw err;
}
setTimeout(s.checkFile, 100, s);
};
state.checkFile(state);