lib/output/json/onFinish.js
function onFinish(output) {
    var book = output.getBook();
    var outputRoot = output.getRoot();

    if (!book.isMultilingual()) {
        return Promise(output);
    }

    // Get main language
    var languages = book.getLanguages();
    var mainLanguage = languages.getDefaultLanguage();

    // Read the main JSON
    return fs.readFile(path.resolve(outputRoot, mainLanguage.getID(), 'README.json'), 'utf8')

    // Extend the JSON
    .then(function(content) {
        var json = JSON.parse(content);

        json.languages = JSONUtils.encodeLanguages(languages);

        return json;
    })

    .then(function(json) {
        return fs.writeFile(
            path.resolve(outputRoot, 'README.json'),
            JSON.stringify(json, null, 4)
        );
    })

    .thenResolve(output);
}
function onFinish(output) {
    var book = output.getBook();
    var outputRoot = output.getRoot();

    if (!book.isMultilingual()) {
        return Promise(output);
    }

    // Get main language
    var languages = book.getLanguages();
    var mainLanguage = languages.getDefaultLanguage();

    // Read the main JSON
    return fs.readFile(path.resolve(outputRoot, mainLanguage.getID(), 'README.json'), 'utf8')

    // Extend the JSON
    .then(function(content) {
        var json = JSON.parse(content);

        json.languages = JSONUtils.encodeLanguages(languages);

        return json;
    })

    .then(function(json) {
        return fs.writeFile(
            path.resolve(outputRoot, 'README.json'),
            JSON.stringify(json, null, 4)
        );
    })

    .thenResolve(output);
}
function onFinish ( output ) { var book = output . getBook ( ) ; var outputRoot = output . getRoot ( ) ; if ( ! book . isMultilingual ( ) ) { return Promise ( output ) ; } // Get main language var languages = book . getLanguages ( ) ; var mainLanguage = languages . getDefaultLanguage ( ) ; // Read the main JSON return fs . readFile ( path . resolve ( outputRoot , mainLanguage . getID ( ) , 'README.json' ) , 'utf8' ) // Extend the JSON . then ( function ( content ) { var json = JSON . parse ( content ) ; json . languages = JSONUtils . encodeLanguages ( languages ) ; return json ; } ) . then ( function ( json ) { return fs . writeFile ( path . resolve ( outputRoot , 'README.json' ) , JSON . stringify ( json , null , 4 ) ) ; } ) . thenResolve ( output ) ; }
Finish the generation

@param {Output}
@return {Output}
Finish the generation