Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
qscript
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Кубота
qscript
Commits
fdc273f4
Commit
fdc273f4
authored
Jun 05, 2017
by
Иван Кубота
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
require. get path of file
parent
149574ef
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
10 deletions
+42
-10
QRequire.js
bin/QRequire.js
+21
-6
cmd.js
bin/cmd.js
+19
-4
test1.qs
test/test1.qs
+2
-0
No files found.
bin/QRequire.js
View file @
fdc273f4
...
...
@@ -11,13 +11,13 @@ module.exports = (function () {
var
slice
=
[].
slice
;
var
waiting
=
{};
var
deps
=
{};
var
Waiter
=
function
(
args
,
fn
){
var
Waiter
=
function
(
args
,
fn
,
path
){
var
argsPos
=
this
.
argsPos
=
{},
i
,
_i
;
this
.
args
=
args
;
this
.
deps
=
args
.
slice
();
this
.
count
=
args
.
length
;
this
.
fn
=
fn
;
this
.
path
=
path
;
for
(
i
=
0
,
_i
=
args
.
length
;
i
<
_i
;
i
++
){
argsPos
[
args
[
i
]]
=
i
;
}
...
...
@@ -54,13 +54,23 @@ module.exports = (function () {
this
.
sub
();
}
};
var
QRequire
=
function
(){
var
args
=
slice
.
call
(
arguments
),
fn
=
args
.
pop
()
,
fn
=
args
.
pop
()
;
waiter
=
new
Waiter
(
args
,
fn
),
i
,
_i
,
arg
;
/*compiling tool*/
var
tmp
=
Error
.
prepareStackTrace
;
Error
.
prepareStackTrace
=
function
(
err
,
stack
)
{
return
stack
;
};
var
err
=
new
Error
(),
errFile
=
err
.
stack
[
1
].
getFileName
();
Error
.
prepareStackTrace
=
tmp
;
/* end compiling*/
var
waiter
=
new
Waiter
(
args
,
fn
,
errFile
),
i
,
_i
,
arg
;
for
(
i
=
0
,
_i
=
args
.
length
;
i
<
_i
;
i
++
){
arg
=
args
[
i
];
if
(
!
(
arg
in
waiting
)){
...
...
@@ -72,6 +82,7 @@ module.exports = (function () {
waiting
[
arg
].
push
(
waiter
);
if
(
arg
.
indexOf
(
'.'
)
===-
1
){
QRequire
.
loaded
(
arg
,
require
(
arg
));
(
waiter
.
paths
||
(
waiter
.
paths
=
[])).
push
(
require
.
cache
[
require
.
resolve
(
arg
)])
}
}
}
...
...
@@ -79,7 +90,7 @@ module.exports = (function () {
//waiter.may();
};
QRequire
.
loaded
=
function
(
name
,
obj
){
console
.
log
(
name
,
typeof
obj
)
//
console.log(name, typeof obj)
var
waiter
=
waiting
[
name
];
if
(
waiter
instanceof
Array
){
for
(
var
i
=
0
,
_i
=
waiter
.
length
;
i
<
_i
;
i
++
){
...
...
@@ -92,5 +103,8 @@ module.exports = (function () {
QRequire
.
deps
=
function
(
name
){
return
(
deps
[
name
]
||
{}).
deps
;
};
QRequire
.
path
=
function
(
name
){
return
(
deps
[
name
]
||
{}).
path
;
};
return
QRequire
;
})();
\ No newline at end of file
bin/cmd.js
View file @
fdc273f4
...
...
@@ -28,6 +28,8 @@ QRequire('quokka-script', 'quokka-core', 'Core.TypeTable', 'fs', function(qs, QC
}
fullName
=
getName
(
main
,
all
);
//var cfg = TypeTable.search(fullName);
/*if (cfg.length) {
cfg = cfg[0];
...
...
@@ -35,11 +37,20 @@ QRequire('quokka-script', 'quokka-core', 'Core.TypeTable', 'fs', function(qs, QC
} else
;//throw new Error('No source for '+fullName)
*/
var
dep
=
QRequire
.
deps
(
fullName
);
var
jsDeps
=
QRequire
.
deps
(
fullName
);
if
(
!
(
fullName
in
store
.
names
))
{
store
.
names
[
fullName
]
=
dep
;
store
.
list
.
push
({
name
:
fullName
,
deps
:
dep
});
store
.
names
[
fullName
]
=
jsDeps
;
store
.
list
.
push
({
name
:
fullName
,
deps
:
jsDeps
,
path
:
QRequire
.
path
(
fullName
)});
}
jsDeps
&&
jsDeps
.
forEach
(
function
(
dep
)
{
if
(
!
(
dep
in
store
.
names
))
{
store
.
names
[
dep
]
=
true
;
store
.
list
.
push
({
name
:
dep
,
path
:
QRequire
.
path
(
dep
)});
}
});
/*cache[fullName] = {
require: deps ? Object.keys(deps).map(function (name) {
...
...
@@ -56,7 +67,11 @@ QRequire('quokka-script', 'quokka-core', 'Core.TypeTable', 'fs', function(qs, QC
newWay
:
true
},
function
(
result
)
{
var
mainObj
=
result
.
main
;
var
deps
=
startDepsResolve
(
mainObj
,
result
.
world
);
var
deps
=
startDepsResolve
(
mainObj
,
result
.
world
).
list
.
filter
(
function
(
dep
)
{
return
dep
.
path
});
console
.
log
(
deps
)
require
cache
});
...
...
test/test1.qs
View file @
fdc273f4
...
...
@@ -5,5 +5,6 @@
def Page main
Slider s1: 10
from:22
div: ee
td: de
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment