diff --git a/bin/build.wsf b/bin/build.wsf
index d66949b..e9f7aca 100644
--- a/bin/build.wsf
+++ b/bin/build.wsf
@@ -5,6 +5,7 @@
+
diff --git a/lib/core/ArrayUtil/ArrayUtil.vbs b/lib/core/ArrayUtil/ArrayUtil.vbs
new file mode 100644
index 0000000..2756a41
--- /dev/null
+++ b/lib/core/ArrayUtil/ArrayUtil.vbs
@@ -0,0 +1,38 @@
+Class ArrayUtil
+
+ Public Function toString(arr)
+ If Not isArray(arr) Then
+ toString = "Supplied parameter is not an array."
+ Exit Function
+ End If
+
+ Dim s, i
+ s = "Array{" & UBound(arr) & "} [" & vbCrLf
+ For i = 0 to UBound(arr)
+ s = s & vbTab & "[" & i & "] => [" & arr(i) & "]"
+ if i < UBound(arr) Then s = s & ", "
+ s = s & vbCrLf
+ Next
+ s = s & "]"
+ toString = s
+
+ End Function
+
+ Public Function contains(arr, s)
+ If Not isArray(arr) Then
+ toString = "Supplied parameter is not an array."
+ Exit Function
+ End If
+
+ Dim i, bFlag
+ bFlag = false
+ For i = 0 to UBound(arr)
+ If arr(i) = s Then
+ bFlag = true
+ Exit For
+ End If
+ Next
+ contains = bFlag
+ End Function
+
+End Class
\ No newline at end of file
diff --git a/lib/core/ArrayUtil/test.cmd b/lib/core/ArrayUtil/test.cmd
new file mode 100644
index 0000000..eda569d
--- /dev/null
+++ b/lib/core/ArrayUtil/test.cmd
@@ -0,0 +1 @@
+cscript //nologo .\test.wsf //job:Test1
\ No newline at end of file
diff --git a/lib/core/ArrayUtil/test.wsf b/lib/core/ArrayUtil/test.wsf
new file mode 100644
index 0000000..f71b14f
--- /dev/null
+++ b/lib/core/ArrayUtil/test.wsf
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/core/FSO/FSO.vbs b/lib/core/FSO/FSO.vbs
index a1aed6a..6010c97 100644
--- a/lib/core/FSO/FSO.vbs
+++ b/lib/core/FSO/FSO.vbs
@@ -60,6 +60,10 @@ Class FSO
GetFileDir = objFSO.GetParentFolderName(objFile)
End Function
+ Public Function GetFilePath(ByVal file)
+ GetFilePath = objFSO.GetFile(file).Path
+ End Function
+
Public Function ReadFile(file)
If Not FileExists(file) Then
Wscript.Echo "File " & file & " does not exists."
diff --git a/lib/core/globals.vbs b/lib/core/globals.vbs
index 1d3c5ed..126ed28 100644
--- a/lib/core/globals.vbs
+++ b/lib/core/globals.vbs
@@ -1,26 +1,45 @@
Dim baseDir
Dim cFS
+Redim IncludedScripts(-1)
+Dim arrUtil
set cFS = new FSO
+set arrUtil = new ArrayUtil
public Sub Echo(msg)
Wscript.Echo msg
End Sub
+
Function log(msg)
cFS.WriteFile "build.log", msg, false
End Function
+
log "================================= Call ================================="
Sub Include(file)
log "Include(" + file + ")"
+ if Lcase(cFS.GetExtn(file)) = "" Then
+ log "File extension missing. Adding .vbs"
+ file = file + ".vbs"
+ end if
+ Dim path: path = cFS.GetFilePath(file)
+ log "File full path: " & path
- Dim content: content = cFS.ReadFile(file)
- if content <> "" Then
- ' Dim pkg
- ' pkg = Replace(file, "\node_modules\", "")
- ' pkg = Replace(pkg, "\index.vbs", "")
- ' cFS.WriteFile "build\imported\" & pkg & ".vbs", content, true
- ExecuteGlobal content
+ ' Dim pkg
+ ' pkg = Replace(file, "\node_modules\", "")
+ ' pkg = Replace(pkg, "\index.vbs", "")
+ ' cFS.WriteFile "build\imported\" & pkg & ".vbs", content, true
+ If Not arrUtil.contains(IncludedScripts, path) Then
+ Redim Preserve IncludedScripts(UBound(IncludedScripts)+1)
+ IncludedScripts(UBound(IncludedScripts)) = path
+ Dim content: content = cFS.ReadFile(file)
+ if content <> "" Then
+ ExecuteGlobal content
+ Else
+ log "File content is empty. Not loaded."
+ End If
+ Else
+ log "File: " & path & " already loaded."
End If
End Sub
diff --git a/lib/core/params.vbs b/lib/core/params.vbs
index 0258db7..a9223fd 100644
--- a/lib/core/params.vbs
+++ b/lib/core/params.vbs
@@ -17,25 +17,15 @@ End If
' TODO: Assess all possible combinations a user can send in command line
file = baseDir & "\" & file
-if Lcase(cFS.GetExtn(file)) = "vbs" Then
- log "File extension is: .vbs"
-Else
+if Lcase(cFS.GetExtn(file)) = "" Then
log "File extension missing. Adding .vbs"
file = file + ".vbs"
end if
-log "File: " & file
-
-
-Dim script
-script = cFS.ReadFile(file)
-if script = "" Then
- log "No file supplied or is empty."
- Wscript.Quit
-End if
-
-
+log "Main Script: " & file
'===========================
-Execute script
-'===========================
\ No newline at end of file
+Include file
+'===========================
+
+' Wscript.Echo arrUtil.toString(IncludedScripts)
\ No newline at end of file
diff --git a/package.json b/package.json
index 9862534..ac655e3 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "vbspm",
- "version": "1.1.3",
+ "version": "1.1.4",
"description": "Vbs Package Manager",
"main": "vbspm.vbs",
"bin": "vbspm.cmd",
diff --git a/vbspm.vbs b/vbspm.vbs
index 20205e2..352fd19 100644
--- a/vbspm.vbs
+++ b/vbspm.vbs
@@ -5,6 +5,45 @@
' ================= src : lib/core/init.vbs =================
Option Explicit
+' ================= src : lib/core/ArrayUtil/ArrayUtil.vbs =================
+Class ArrayUtil
+
+ Public Function toString(arr)
+ If Not isArray(arr) Then
+ toString = "Supplied parameter is not an array."
+ Exit Function
+ End If
+
+ Dim s, i
+ s = "Array{" & UBound(arr) & "} [" & vbCrLf
+ For i = 0 to UBound(arr)
+ s = s & vbTab & "[" & i & "] => [" & arr(i) & "]"
+ if i < UBound(arr) Then s = s & ", "
+ s = s & vbCrLf
+ Next
+ s = s & "]"
+ toString = s
+
+ End Function
+
+ Public Function contains(arr, s)
+ If Not isArray(arr) Then
+ toString = "Supplied parameter is not an array."
+ Exit Function
+ End If
+
+ Dim i, bFlag
+ bFlag = false
+ For i = 0 to UBound(arr)
+ If arr(i) = s Then
+ bFlag = true
+ Exit For
+ End If
+ Next
+ contains = bFlag
+ End Function
+
+End Class
' ================= src : lib/core/FSO/FSO.vbs =================
' ==============================================================================================
' Implementation of several use cases of FileSystemObject into this class
@@ -68,6 +107,10 @@ Class FSO
GetFileDir = objFSO.GetParentFolderName(objFile)
End Function
+ Public Function GetFilePath(ByVal file)
+ GetFilePath = objFSO.GetFile(file).Path
+ End Function
+
Public Function ReadFile(file)
If Not FileExists(file) Then
Wscript.Echo "File " & file & " does not exists."
@@ -836,27 +879,46 @@ end function
' ================= src : lib/core/globals.vbs =================
Dim baseDir
Dim cFS
+Redim IncludedScripts(-1)
+Dim arrUtil
set cFS = new FSO
+set arrUtil = new ArrayUtil
public Sub Echo(msg)
Wscript.Echo msg
End Sub
+
Function log(msg)
cFS.WriteFile "build.log", msg, false
End Function
+
log "================================= Call ================================="
Sub Include(file)
log "Include(" + file + ")"
+ if Lcase(cFS.GetExtn(file)) = "" Then
+ log "File extension missing. Adding .vbs"
+ file = file + ".vbs"
+ end if
+ Dim path: path = cFS.GetFilePath(file)
+ log "File full path: " & path
- Dim content: content = cFS.ReadFile(file)
- if content <> "" Then
- ' Dim pkg
- ' pkg = Replace(file, "\node_modules\", "")
- ' pkg = Replace(pkg, "\index.vbs", "")
- ' cFS.WriteFile "build\imported\" & pkg & ".vbs", content, true
- ExecuteGlobal content
+ ' Dim pkg
+ ' pkg = Replace(file, "\node_modules\", "")
+ ' pkg = Replace(pkg, "\index.vbs", "")
+ ' cFS.WriteFile "build\imported\" & pkg & ".vbs", content, true
+ If Not arrUtil.contains(IncludedScripts, path) Then
+ Redim Preserve IncludedScripts(UBound(IncludedScripts)+1)
+ IncludedScripts(UBound(IncludedScripts)) = path
+ Dim content: content = cFS.ReadFile(file)
+ if content <> "" Then
+ ExecuteGlobal content
+ Else
+ log "File content is empty. Not loaded."
+ End If
+ Else
+ log "File: " & path & " already loaded."
End If
End Sub
@@ -892,25 +954,15 @@ End If
' TODO: Assess all possible combinations a user can send in command line
file = baseDir & "\" & file
-if Lcase(cFS.GetExtn(file)) = "vbs" Then
- log "File extension is: .vbs"
-Else
+if Lcase(cFS.GetExtn(file)) = "" Then
log "File extension missing. Adding .vbs"
file = file + ".vbs"
end if
-log "File: " & file
-
-
-Dim script
-script = cFS.ReadFile(file)
-if script = "" Then
- log "No file supplied or is empty."
- Wscript.Quit
-End if
-
-
+log "Main Script: " & file
'===========================
-Execute script
-'===========================
\ No newline at end of file
+Include file
+'===========================
+
+' Wscript.Echo arrUtil.toString(IncludedScripts)
\ No newline at end of file