Skip to content

Commit

Permalink
fix(inline-script-tester): includeマクロとインラインコードの組み合わせに対応
Browse files Browse the repository at this point in the history
実行マークのために組みわせて書くケースが出来てきたため
  • Loading branch information
azu committed Jun 12, 2014
1 parent 030e3df commit 70bcac9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 12 additions & 2 deletions test/inline-script/inline-script-tester.js
Expand Up @@ -4,14 +4,24 @@ var FS = require("q-io/fs");
var esprima = require("esprima-fb");
var pather = require("path");
// http://www.regexr.com/38t47
var inlineCodeReg = /\[source.*?js\]\n[\s\S]*?----([\s\S]*?)----/gm;
var inlineCodeReg = /\[source.*?javascript\]\n[\s\S]*?----([\s\S]*?)----/gm;
var includeCodeReg = /include::/;
function trimIncludeCode(code) {
var replaceRegExp = /include::.*/g;
var trimedCode = code.replace(replaceRegExp, "");
return trimedCode.trim();
}
function pickupContent(content) {
var results = [];
var matches;
while ((matches = inlineCodeReg.exec(content)) !== null) {
var code = matches[1];
if (!includeCodeReg.test(code)) {
if (includeCodeReg.test(code)) {
var trimedCode = trimIncludeCode(code);
if (trimedCode.length > 0) {
results.push(trimedCode);
}
} else {
results.push(code);
}
}
Expand Down
4 changes: 3 additions & 1 deletion test/inline-script/run-inline-script-test.js
Expand Up @@ -5,5 +5,7 @@
"use strict";
var checkInlineScript = require("./inline-script-tester").checkInlineScript;
checkInlineScript("../../").catch(function (error) {
// console.log(error);
if(error) {
console.error(error);
}
});

0 comments on commit 70bcac9

Please sign in to comment.