Skip to content

Commit a270eee

Browse files
committed
sync w/ jevko-cli
1 parent 70c061d commit a270eee

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

bundlable/deps.bremote.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export {jevkoml} from 'https://raw.githubusercontent.com/jevko/jevkoml/v0.5.1/jevkoml.js'
2-
export {jevkodata, map, prep, prettyFromJsonStr} from 'https://raw.githubusercontent.com/jevko/jevkodata/v0.4.1/mod.js'
2+
export {jevkodata, convert, map, prep, prettyFromJsonStr} from 'https://raw.githubusercontent.com/jevko/jevkodata/v0.4.1/mod.js'
33
export {jevkocfg} from 'https://raw.githubusercontent.com/jevko/jevkoconfig1.js/v0.2.1/jevkocfg.js'
44
export {jevkoFromString as parseJevkoWithHeredocs} from 'https://cdn.jsdelivr.net/gh/jevko/jevko.js@v0.1.5/mod.js'

node/bundle.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,14 +1926,16 @@ var importDirective = (jevko, options) => {
19261926
subs.push(...subjevkos2);
19271927
continue;
19281928
} else if (directive === "paste") {
1929-
const fileName = string2(jevko2);
1929+
const opts = convert(jevko2);
1930+
const fileName = typeof opts === "string" ? opts : opts.path;
1931+
const tag = typeof opts === "string" ? void 0 : opts.tag;
19301932
let path;
19311933
if ((0, import_node_path.isAbsolute)(fileName))
19321934
path = fileName;
19331935
else
19341936
path = (0, import_node_path.join)(dir, fileName);
19351937
const src = readTextFileSync(path);
1936-
subs.push(makeTextNode2(src));
1938+
subs.push(makeTextNode2(src, tag));
19371939
continue;
19381940
}
19391941
}
@@ -1947,16 +1949,17 @@ var string2 = (jevko) => {
19471949
throw Error("oops");
19481950
return suffix;
19491951
};
1950-
var makeTextNode2 = (text) => {
1952+
var makeTextNode2 = (text, tag) => {
19511953
return {
19521954
prefix: "",
1953-
jevko: suffixToJevko2(text)
1955+
jevko: suffixToJevko2(text, tag)
19541956
};
19551957
};
1956-
var suffixToJevko2 = (suffix) => {
1958+
var suffixToJevko2 = (suffix, tag) => {
19571959
return {
19581960
subjevkos: [],
1959-
suffix
1961+
suffix,
1962+
tag
19601963
};
19611964
};
19621965

portable/importDirective.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { dirname, join, isAbsolute, readTextFileSync } from "../nonportable/deps.js";
2-
import {parseJevkoWithHeredocs} from '../bundlable/deps.b.js'
2+
import {convert, parseJevkoWithHeredocs} from '../bundlable/deps.b.js'
33

44
//?todo: extract to a separate lib
55
//?todo: handle via streaming (requires rearchitecting and rewriting the entire jevko cli)
@@ -46,7 +46,10 @@ export const importDirective = (jevko, options) => {
4646
// paste: how to be consistent accross formats?
4747
// maybe paste as `/jevko:paste/.../jevko:paste/
4848

49-
const fileName = string(jevko)
49+
const opts = convert(jevko)
50+
51+
const fileName = typeof opts === 'string'? opts: opts.path
52+
const tag = typeof opts === 'string'? undefined: opts.tag
5053

5154
let path
5255
if (isAbsolute(fileName)) path = fileName
@@ -55,7 +58,7 @@ export const importDirective = (jevko, options) => {
5558
// console.log(isAbsolute(fileName), fileName, dir, path)
5659

5760
const src = readTextFileSync(path)
58-
subs.push(makeTextNode(src))
61+
subs.push(makeTextNode(src, tag))
5962
continue
6063
}
6164
// note: unknown directives are treated as normal subjevkos
@@ -75,15 +78,16 @@ const string = jevko => {
7578
return suffix
7679
}
7780

78-
const makeTextNode = text => {
81+
const makeTextNode = (text, tag) => {
7982
return {
8083
prefix: "",
81-
jevko: suffixToJevko(text),
84+
jevko: suffixToJevko(text, tag),
8285
}
8386
}
84-
const suffixToJevko = suffix => {
87+
const suffixToJevko = (suffix, tag) => {
8588
return {
8689
subjevkos: [],
8790
suffix,
91+
tag,
8892
}
8993
}

0 commit comments

Comments
 (0)