:: pkg-build.bat
:: Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
:: 
:: Contact:
:: DongHee Yang <donghee.yang@samsung.com>
:: Sungmin Kim <sm.art.kim@samsung.com>
:: Jiil Hyoun <jiil.hyoun@samsung.com>
:: Jonghwan Park <iwin100.park@samsung.com>
:: Kitae Kim <kt920.kim@samsung.com>
:: 
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
:: 
:: http://www.apache.org/licenses/LICENSE-2.0
:: 
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
:: 
:: Contributors:
:: - S-Core Co., Ltd

@echo off

set BASEDIR=%~dp0
set APP=""

if exist %BASEDIR%/pkg-build.js (
    set APP=%BASEDIR%/pkg-build.js
)
if exist %BASEDIR%/../plugins/org.tizen.cli-tools/pkg-build.js (
    set APP=%BASEDIR%/../plugins/org.tizen.cli-tools/pkg-build.js
)
if %APP% EQU "" (
    echo Can not find package build module
    GOTO DONE
)

reg query HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall /s > %TMP%\regresult.txt
find /C "Node.js" %TMP%\regresult.txt > %TMP%\result.txt
FOR /f "tokens=3" %%p in (%TMP%\result.txt) do set result=%%p

IF "%result%" == "0" (
    echo Can not find node.
    GOTO DONE
)
Del %TMP%\result.txt
Del %TMP%\regresult.txt

node %APP% %*
GOTO DONE

:DONE
