diff --git a/local-cli/bundle/__tests__/saveBundleAndMap-test.js b/local-cli/bundle/__tests__/saveBundleAndMap-test.js index f828b7346..1d155e273 100644 --- a/local-cli/bundle/__tests__/saveBundleAndMap-test.js +++ b/local-cli/bundle/__tests__/saveBundleAndMap-test.js @@ -41,10 +41,11 @@ describe('saveBundleAndMap', () => { saveBundleAndMap( codeWithMap, 'ios', - bundleOutput + bundleOutput, + 'utf8', ); - expect(fs.writeFileSync.mock.calls[0]).toEqual([bundleOutput, code]); + expect(fs.writeFileSync.mock.calls[0]).toEqual([bundleOutput, code, 'utf8']); }); it('should save sourcemaps if required so', () => { @@ -55,6 +56,7 @@ describe('saveBundleAndMap', () => { codeWithMap, 'ios', bundleOutput, + 'utf8', sourceMapOutput ); diff --git a/local-cli/bundle/buildBundle.js b/local-cli/bundle/buildBundle.js index d16485e26..1260868d5 100644 --- a/local-cli/bundle/buildBundle.js +++ b/local-cli/bundle/buildBundle.js @@ -49,6 +49,7 @@ function buildBundle(args, config) { outputBundle, args.platform, args['bundle-output'], + args['bundle-encoding'], args['sourcemap-output'], args['assets-dest'] )); diff --git a/local-cli/bundle/bundleCommandLineArgs.js b/local-cli/bundle/bundleCommandLineArgs.js index 77033b11a..353c7ea5f 100644 --- a/local-cli/bundle/bundleCommandLineArgs.js +++ b/local-cli/bundle/bundleCommandLineArgs.js @@ -32,6 +32,11 @@ module.exports = [ description: 'File name where to store the resulting bundle, ex. /tmp/groups.bundle', type: 'string', required: true, + }, { + command: 'bundle-encoding', + description: 'Encoding the bundle should be written in (https://nodejs.org/api/buffer.html#buffer_buffer).', + type: 'string', + default: 'utf8', }, { command: 'sourcemap-output', description: 'File name where to store the sourcemap file for resulting bundle, ex. /tmp/groups.map', diff --git a/local-cli/bundle/saveBundleAndMap.js b/local-cli/bundle/saveBundleAndMap.js index 27b987850..bb6bf2291 100644 --- a/local-cli/bundle/saveBundleAndMap.js +++ b/local-cli/bundle/saveBundleAndMap.js @@ -20,11 +20,12 @@ function saveBundleAndMap( codeWithMap, platform, bundleOutput, + encoding, sourcemapOutput, assetsDest ) { log('Writing bundle output to:', bundleOutput); - fs.writeFileSync(bundleOutput, sign(codeWithMap.code)); + fs.writeFileSync(bundleOutput, sign(codeWithMap.code), encoding); log('Done writing bundle output'); if (sourcemapOutput) {