forked from philipashlock/mediawiki-to-markdown
-
Notifications
You must be signed in to change notification settings - Fork 9
/
convert.ps1
40 lines (32 loc) · 1.17 KB
/
convert.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
[CmdletBinding()]
Param(
[string]$convertFileArgFullPath = "wiki.xml"
)
function RefreshDirectory([string] $pathToDirectory)
{
if (!(Test-Path $pathToDirectory -PathType Container))
{
Write-Host -Message "Creating $pathToDirectory."
New-Item -Path $pathToDirectory -Type directory | out-null
}
else
{
Write-Host -Message "Deleting and recreating $pathToDirectory."
Remove-Item $pathToDirectory -Recurse -Force
New-Item -Path $pathToDirectory -Type directory | out-null
}
}
if(!$PSScriptRoot){
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
}
$inputFolder = Join-Path $PSScriptRoot "input"
$outputFolder = Join-Path $PSScriptRoot "output"
RefreshDirectory $inputFolder
Copy-Item $convertFileArgFullPath $inputFolder
$fileToConvertFileName = Split-Path $convertFileArgFullPath -Leaf
$fileToConvertPathForDockerImage = "./input/"+$fileToConvertFileName
$image = "wiki2md"
docker build -t $image .
RefreshDirectory $outputFolder
$dockerRunCmd = "php convert.php --filename="+$fileToConvertPathForDockerImage+" --output=./output"
docker run -v ${PSScriptRoot}/output/:/src/output $image sh -c $dockerRunCmd