src/cordova/platform.js
function getPlatformDetailsFromDir(dir, platformIfKnown){
    var libDir = path.resolve(dir);
    var platform;
    var version;

    try {
        var pkg = require(path.join(libDir, 'package'));
        platform = platformFromName(pkg.name);
        version = pkg.version;
    } catch(e) {
        // Older platforms didn't have package.json.
        platform = platformIfKnown || platformFromName(path.basename(dir));
        var verFile = fs.existsSync(path.join(libDir, 'VERSION')) ? path.join(libDir, 'VERSION') :
                      fs.existsSync(path.join(libDir, 'CordovaLib', 'VERSION')) ? path.join(libDir, 'CordovaLib', 'VERSION') : null;
        if (verFile) {
            version = fs.readFileSync(verFile, 'UTF-8').trim();
        }
    }

    // if (!version || !platform || !platforms[platform]) {
    //     return Q.reject(new CordovaError('The provided path does not seem to contain a ' +
    //         'Cordova platform: ' + libDir));
    // }

    return Q({
        libDir: libDir,
        platform: platform || platformIfKnown,
        version: version || '0.0.1'
    });
}
function getPlatformDetailsFromDir(dir, platformIfKnown){
    var libDir = path.resolve(dir);
    var platform;
    var version;

    try {
        var pkg = require(path.join(libDir, 'package'));
        platform = platformFromName(pkg.name);
        version = pkg.version;
    } catch(e) {
        // Older platforms didn't have package.json.
        platform = platformIfKnown || platformFromName(path.basename(dir));
        var verFile = fs.existsSync(path.join(libDir, 'VERSION')) ? path.join(libDir, 'VERSION') :
                      fs.existsSync(path.join(libDir, 'CordovaLib', 'VERSION')) ? path.join(libDir, 'CordovaLib', 'VERSION') : null;
        if (verFile) {
            version = fs.readFileSync(verFile, 'UTF-8').trim();
        }
    }

    // if (!version || !platform || !platforms[platform]) {
    //     return Q.reject(new CordovaError('The provided path does not seem to contain a ' +
    //         'Cordova platform: ' + libDir));
    // }

    return Q({
        libDir: libDir,
        platform: platform || platformIfKnown,
        version: version || '0.0.1'
    });
}
function getPlatformDetailsFromDir ( dir , platformIfKnown ) { var libDir = path . resolve ( dir ) ; var platform ; var version ; try { var pkg = require ( path . join ( libDir , 'package' ) ) ; platform = platformFromName ( pkg . name ) ; version = pkg . version ; } catch ( e ) { // Older platforms didn't have package.json. platform = platformIfKnown || platformFromName ( path . basename ( dir ) ) ; var verFile = fs . existsSync ( path . join ( libDir , 'VERSION' ) ) ? path . join ( libDir , 'VERSION' ) : fs . existsSync ( path . join ( libDir , 'CordovaLib' , 'VERSION' ) ) ? path . join ( libDir , 'CordovaLib' , 'VERSION' ) : null ; if ( verFile ) { version = fs . readFileSync ( verFile , 'UTF-8' ) . trim ( ) ; } } // if (!version || !platform || !platforms[platform]) { //     return Q.reject(new CordovaError('The provided path does not seem to contain a ' + //         'Cordova platform: ' + libDir)); // } return Q ( { libDir : libDir , platform : platform || platformIfKnown , version : version || '0.0.1' } ) ; }
Returns a Promise Gets platform details from a directory
Returns a Promise Gets platform details from a directory