Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 15x 15x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x | #!/usr/bin/env node
/* global process */
/**
* Thin wrapper around the stamp-textdomains library. Run from a package
* directory, it stamps that package's text domain onto every gettext call in
* the built JS bundles so translations resolve at runtime.
*
* The domain is read from `composer.json` `extra.textdomain` in the current
* working directory, or overridden with `--domain`. The build directory
* defaults to `build`, overridable with `--dir`. Stamped results are cached in
* `node_modules/.cache/stamp-textdomains` so rebuilds only re-stamp changed
* bundles; `--no-cache` turns that off.
*
* See `stamp-textdomains-lib.js` for context and behaviour details.
*/
const path = require( 'path' );
const { resolveTextdomain } = require( './package-textdomain-lib.js' );
const { stampDir, writeI18nManifest } = require( './stamp-textdomains-lib.js' );
const args = process.argv.slice( 2 );
const getFlag = name => {
const i = args.indexOf( `--${ name }` );
return i >= 0 ? args[ i + 1 ] : undefined;
};
const domain = resolveTextdomain( getFlag( 'domain' ), 'stamp-textdomains' );
const buildDir = path.resolve( getFlag( 'dir' ) || 'build' );
// CI starts cold, and the e2e build artifact would otherwise ship the cache files.
const cacheDir =
args.includes( '--no-cache' ) || process.env.CI
? undefined
: path.resolve( 'node_modules', '.cache', 'stamp-textdomains' );
const { count, reused, stringBearing } = stampDir( buildDir, domain, { cacheDir } );
const bundles = writeI18nManifest( buildDir, stringBearing );
// eslint-disable-next-line no-console
console.log(
`stamp-textdomains: stamped "${ domain }" onto ${ count } file(s) in ${ buildDir } (${ reused } reused from cache); ${ bundles.length } string-bearing bundle(s) listed in the i18n manifest`
);
|