feat: implement basic feature working for Linux only

This commit is contained in:
Kengo TODA
2020-08-27 20:39:35 +08:00
parent 74c8587e44
commit 367ba4923b
11 changed files with 4741 additions and 77 deletions

View File

@@ -0,0 +1,6 @@
import {runCommand} from '../src/install'
test('runCommand', async () => {
const result = await runCommand('echo foo bar')
expect(result).toBe('foo bar')
})

View File

@@ -1,27 +0,0 @@
import {wait} from '../src/wait'
import * as process from 'process'
import * as cp from 'child_process'
import * as path from 'path'
test('throws invalid number', async () => {
const input = parseInt('foo', 10)
await expect(wait(input)).rejects.toThrow('milliseconds not a number')
})
test('wait 500 ms', async () => {
const start = new Date()
await wait(500)
const end = new Date()
var delta = Math.abs(end.getTime() - start.getTime())
expect(delta).toBeGreaterThan(450)
})
// shows how the runner will run a javascript action with env / stdout protocol
test('test runs', () => {
process.env['INPUT_MILLISECONDS'] = '500'
const ip = path.join(__dirname, '..', 'lib', 'main.js')
const options: cp.ExecSyncOptions = {
env: process.env
}
console.log(cp.execSync(`node ${ip}`, options).toString())
})