@quailjs/quail-cli
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -7,10 +7,9 @@ 'use strict'; | ||
var appOpener = require('opener'); | ||
var assessmentSpecsPath = path.join(__dirname, '..', '..', 'test', 'assessmentSpecs', 'specs'); | ||
var config = require('./config'); | ||
var cwd = process.cwd(); | ||
var state = {}; | ||
/** | ||
* | ||
*/ | ||
function serveAssessmentTestPage(response, assessmentName) { | ||
// Load up a page with the assessment test page. | ||
fs.readFile(path.join(assessmentSpecsPath, assessmentName, assessmentName + '.html'), 'utf-8', function (err, source) { | ||
fs.readFile(path.join(state.assessmentSpecsPath, assessmentName, assessmentName + '.html'), 'utf-8', function (err, source) { | ||
if (err) { | ||
@@ -24,5 +23,5 @@ console.error('\n' + err + '\n'); | ||
// Javascript resources. | ||
source += '<script src="node_modules/jquery/dist/jquery.min.js" type="application/javascript"></script>'; | ||
source += '<script src="' + state.jquery + '" type="application/javascript"></script>'; | ||
source += ['<script>', 'window.assessmentName = \'' + assessmentName + '\';', '</script>'].join('\n'); | ||
source += '<script src="dist/runInBrowser.js" type="application/javascript"></script>'; | ||
source += '<script src="' + state.quail + '" type="application/javascript"></script>'; | ||
@@ -39,3 +38,3 @@ source += bodyTag + '</html>'; | ||
function serveScriptResource(response, resourcePath) { | ||
fs.readFile(path.join(__dirname, '..', '..', resourcePath), 'utf-8', function (err, source) { | ||
fs.readFile(path.join(cwd, resourcePath), 'utf-8', function (err, source) { | ||
if (err) { | ||
@@ -104,3 +103,3 @@ response.writeHead(404, { | ||
else if (accepts.indexOf('image') > -1) { | ||
assetPath = path.join(assessmentSpecsPath, assessmentName, url); | ||
assetPath = path.join(state.assessmentSpecsPath, assessmentName, url); | ||
serveAssetResource(response, assetPath); | ||
@@ -111,2 +110,7 @@ } | ||
serveScriptResource(response, url); | ||
} else if (url.indexOf('.ico') > -1) { | ||
response.writeHead(415, { | ||
'Content-Type': 'text/html' | ||
}); | ||
response.end('<!DOCTYPE html>\n<html><body><p>We ain\'t got none.</p></body></html>'); | ||
} | ||
@@ -135,3 +139,8 @@ // 406 | ||
// Get a list of assessments. | ||
fs.readdir(assessmentSpecsPath, processAssessments.bind(this, assessmentName, cmd)); | ||
config.getLocalConfig(function (data) { | ||
state.jquery = data.jquery; | ||
state.quail = data.quail; | ||
state.assessmentSpecsPath = data.assessmentSpecsPath; | ||
fs.readdir(state.assessmentSpecsPath, processAssessments.bind(this, assessmentName, cmd)); | ||
}); | ||
}; |
{ | ||
"name": "@quailjs/quail-cli", | ||
"description": "The Quail command line interface", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"author": "Jesse Beach <jesse.r.beach@gmail.com>", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15175
8
283
3