dts2as
Version:
A command line tool that converts TypeScript definitions (d.ts files) to ActionScript 3 classes and interfaces
59 lines (55 loc) • 1.9 kB
JavaScript
;
/*
Copyright 2015-2017 Bowler Hat LLC
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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
var fs = require("fs");
var path = require("path");
var os = require("os");
function isValidApacheFlexJSPath(sdkPath) {
var sdkDescriptionPath = path.join(sdkPath, "flex-sdk-description.xml");
if (!fs.existsSync(sdkDescriptionPath) || fs.statSync(sdkDescriptionPath).isDirectory()) {
return false;
}
var asjscPath = path.join(sdkPath, "js", "bin", "asjsc");
if (!fs.existsSync(asjscPath) || fs.statSync(asjscPath).isDirectory()) {
return false;
}
return true;
}
exports.isValidApacheFlexJSPath = isValidApacheFlexJSPath;
function findFlexHome() {
if (!("FLEX_HOME" in process.env)) {
return null;
}
var sdkPath = process.env.FLEX_HOME;
if (!isValidApacheFlexJSPath(sdkPath)) {
return null;
}
return sdkPath;
}
exports.findFlexHome = findFlexHome;
function findBinCompc(flexHome) {
if (!isValidApacheFlexJSPath(flexHome)) {
return null;
}
var executableName = "compc";
if (os.platform() === "win32") {
executableName += ".bat";
}
var executablePath = path.join(flexHome, "bin", executableName);
if (!fs.existsSync(executablePath)) {
return null;
}
return executablePath;
}
exports.findBinCompc = findBinCompc;