src/utils/ExtensionUtils.js
function loadMetadata(folder) {
        var packageJSONFile = FileSystem.getFileForPath(folder + "/package.json"),
            disabledFile = FileSystem.getFileForPath(folder + "/.disabled"),
            baseName = FileUtils.getBaseName(folder),
            result = new $.Deferred(),
            jsonPromise = new $.Deferred(),
            disabledPromise = new $.Deferred(),
            json,
            disabled;
        FileUtils.readAsText(packageJSONFile)
            .then(function (text) {
                try {
                    json = JSON.parse(text);
                    jsonPromise.resolve();
                } catch (e) {
                    jsonPromise.reject();
                }
            })
            .fail(jsonPromise.reject);
        disabledFile.exists(function (err, exists) {
            if (err) {
                disabled = false;
            } else {
                disabled = exists;
            }

            var defaultDisabled = PreferencesManager.get("extensions.default.disabled");
            if (Array.isArray(defaultDisabled) && defaultDisabled.indexOf(folder) !== -1) {
                console.warn("Default extension has been disabled on startup: " + baseName);
                disabled = true;
            }

            disabledPromise.resolve();
        });
        Async.waitForAll([jsonPromise, disabledPromise])
            .always(function () {
                if (!json) {
                    // if we don't have any metadata for the extension
                    // we should still create an empty one, so we can attach
                    // disabled property on it in case it's disabled
                    json = {
                        name: baseName
                    };
                }
                json.disabled = disabled;
                result.resolve(json);
            });
        return result.promise();
    }
function loadMetadata(folder) {
        var packageJSONFile = FileSystem.getFileForPath(folder + "/package.json"),
            disabledFile = FileSystem.getFileForPath(folder + "/.disabled"),
            baseName = FileUtils.getBaseName(folder),
            result = new $.Deferred(),
            jsonPromise = new $.Deferred(),
            disabledPromise = new $.Deferred(),
            json,
            disabled;
        FileUtils.readAsText(packageJSONFile)
            .then(function (text) {
                try {
                    json = JSON.parse(text);
                    jsonPromise.resolve();
                } catch (e) {
                    jsonPromise.reject();
                }
            })
            .fail(jsonPromise.reject);
        disabledFile.exists(function (err, exists) {
            if (err) {
                disabled = false;
            } else {
                disabled = exists;
            }

            var defaultDisabled = PreferencesManager.get("extensions.default.disabled");
            if (Array.isArray(defaultDisabled) && defaultDisabled.indexOf(folder) !== -1) {
                console.warn("Default extension has been disabled on startup: " + baseName);
                disabled = true;
            }

            disabledPromise.resolve();
        });
        Async.waitForAll([jsonPromise, disabledPromise])
            .always(function () {
                if (!json) {
                    // if we don't have any metadata for the extension
                    // we should still create an empty one, so we can attach
                    // disabled property on it in case it's disabled
                    json = {
                        name: baseName
                    };
                }
                json.disabled = disabled;
                result.resolve(json);
            });
        return result.promise();
    }
function loadMetadata ( folder ) { var packageJSONFile = FileSystem . getFileForPath ( folder + "/package.json" ) , disabledFile = FileSystem . getFileForPath ( folder + "/.disabled" ) , baseName = FileUtils . getBaseName ( folder ) , result = new $ . Deferred ( ) , jsonPromise = new $ . Deferred ( ) , disabledPromise = new $ . Deferred ( ) , json , disabled ; FileUtils . readAsText ( packageJSONFile ) . then ( function ( text ) { try { json = JSON . parse ( text ) ; jsonPromise . resolve ( ) ; } catch ( e ) { jsonPromise . reject ( ) ; } } ) . fail ( jsonPromise . reject ) ; disabledFile . exists ( function ( err , exists ) { if ( err ) { disabled = false ; } else { disabled = exists ; } var defaultDisabled = PreferencesManager . get ( "extensions.default.disabled" ) ; if ( Array . isArray ( defaultDisabled ) && defaultDisabled . indexOf ( folder ) !== - 1 ) { console . warn ( "Default extension has been disabled on startup: " + baseName ) ; disabled = true ; } disabledPromise . resolve ( ) ; } ) ; Async . waitForAll ( [ jsonPromise , disabledPromise ] ) . always ( function ( ) { if ( ! json ) { // if we don't have any metadata for the extension // we should still create an empty one, so we can attach // disabled property on it in case it's disabled json = { name : baseName } ; } json . disabled = disabled ; result . resolve ( json ) ; } ) ; return result . promise ( ) ; }
Loads the package.json file in the given extension folder as well as any additional
metadata.

If there's a .disabled file in the extension directory, then the content of package.json
will be augmented with disabled property set to true. It will override whatever value of
disabled might be set.

@param {string} folder The extension folder.
@return {$.Promise} A promise object that is resolved with the parsed contents of the package.json file,
or rejected if there is no package.json with the boolean indicating whether .disabled file exists.
Loads the package . json file in the given extension folder as well as any additional metadata .