Skip to content

Commit

Permalink
Merge pull request #33 from slheavner/feature/init-test
Browse files Browse the repository at this point in the history
update test framework and make init better
  • Loading branch information
Samuel Heavner authored Apr 27, 2018
2 parents 3233b75 + 98083a4 commit 34bfe80
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 60 deletions.
62 changes: 39 additions & 23 deletions bin/ukor-init.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,53 @@
'use strict'

const path = require('path')
const fs = require('fs')
const log = require('../lib/utils/log')
const yaml = require('js-yaml')
try {
fs.mkdir('./src', () => {
fs.mkdir('./src', (err) => {
if (err && err.code !== 'EEXIST') throw err
log.info('created ./src directory')
})
fs.mkdir('./src/main', () => {
fs.mkdir('./src/main', (err) => {
if (err && err.code !== 'EEXIST') throw err
log.info('created ./src/main directory')
})
fs.mkdir('./src/test', () => {
log.info('created ./src/main directory')
fs.mkdir('./src/test', (err) => {
if (err && err.code !== 'EEXIST') throw err
log.info('created ./src/test directory')
})
fs.mkdir('./src/test/source', (err) => {
if (err && err.code !== 'EEXIST') throw err
log.info('created ./src/test/source directory')
})
fs.copyFile(path.resolve(__dirname, '../lib/raw/UnitTestFramework.brs'), './src/test/source/UnitTestFramework.brs', (err) => {
if (err && err.code !== 'EEXIST') throw err
log.info('copied UnitTestFramework.brs to ./src/test/source/')
})
fs.copyFile(path.resolve(__dirname, '../lib/raw/default.properties'), './src/test/source/ukor.properties', (err) => {
if (err && err.code !== 'EEXIST') throw err
log.info('copy default properties to ukor.properties')
})

const project = fs.createWriteStream('./ukor.properties.yaml')
const defaults = {
name: path.basename(process.cwd()),
version: '0.0.1',
buildDir: 'build',
sourceDir: 'src',
mainFlavor: 'main',
flavors: {
main: {
src: ['main']
}
}
}
project.write(yaml.safeDump(defaults), () => {
project.close()
log.info('created ukor.properties.yaml')
})

} catch (e) {
log.error(e.message)
}

let defaultProperties =
'name: '+ path.basename(process.cwd()) +'\n' +
'version: 0.0.1\n' +
'buildDir: build\n' +
'sourceDir: src\n' +
'mainFlavor: main\n'

const localProperties = fs.createWriteStream('./ukor.local')
localProperties.write('', () => {
localProperties.close()
log.info('Created ukor.local')
})

const project = fs.createWriteStream('./ukor.properties.yaml')
project.write(defaultProperties, () => {
project.close()
log.info('created ukor.properties.yaml')
})
9 changes: 2 additions & 7 deletions bin/ukor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ const properties = require('../lib/utils/properties')

program
.arguments('[flavor] [roku]')
.option(
'-e, --external <url>',
'Send test result json to something other than ukor'
)
.option(
'-p, --port <port>',
'Specify a port for ukor to receive the test results'
Expand All @@ -27,7 +23,6 @@ let options = {
roku: properties.defaults['roku'],
auth: null,
port: '8080',
url: null,
name: '_test'
}
if (program['flavor']) {
Expand All @@ -42,8 +37,8 @@ if (options.flavor == null || options.flavor == '') {
if (program['port']) {
options.port = program.port
}
if (program['roku']) {
options.roku = program.roku
if (args.length > 1) {
options.roku = args[1]
}
if (
options.roku == null ||
Expand Down
Loading

0 comments on commit 34bfe80

Please sign in to comment.