Cordova-CLI 후크 스크립트에 명령 매개 변수를 전달하는 방법이 있습니까? 특히 저는 몇몇 클라이언트를위한 애플리케이션을 스킨하고 싶습니다. 그리고 빌드 전에 ID 번호 등을 전달하여 특정 설정을 복사하고 싶습니다.
환경 변수를 통해 Cordova 후크에 전달 된 매개 변수에 액세스 할 수 있습니다. 현재 세션에 대해 '활성'상태로 유지되는 환경 변수를 설정할 수 있습니다.
예를 들어 'TARGET'이라는 변수가있는 경우 :
Windows cmd :
SET TARGET=someValue
cordova build android
Powershell :
$env:TARGET = "someValue"
iex "cordova build android"
그런 다음 다음 구문을 사용하여 후크에서 이러한 환경 변수에 액세스 할 수 있습니다 (이는 node.js로 후크를 작성한다고 가정합니다).
var target = "someDefaultValue";
// Check for existence of the environment variable
if (process.env.TARGET) {
// Log the value to the console
console.log('process.env.TARGET is set to: ' + process.env.TARGET);
// Override the default
target = process.env.TARGET;
}
// Log the set value
console.log('Target is set to: ' + target);
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다