From d0398bfeb510cae9f0c9e6bd0d9506a9b35b8b1f Mon Sep 17 00:00:00 2001 From: Muhammed Thanish Date: Fri, 26 Aug 2016 15:26:03 +0530 Subject: [PATCH] Set the app name if possible --- generators/REACT_NATIVE/index.js | 12 ++++++++++++ .../REACT_NATIVE/template/storybook/index.ios.js | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/generators/REACT_NATIVE/index.js b/generators/REACT_NATIVE/index.js index 4bb5a6d7a02d..3ca006815a21 100644 --- a/generators/REACT_NATIVE/index.js +++ b/generators/REACT_NATIVE/index.js @@ -1,9 +1,21 @@ var mergeDirs = require('merge-dirs').default; var helpers = require('../../lib/helpers'); var path = require('path'); +var shell = require('shelljs'); +// copy all files from the template directory to project directory mergeDirs(path.resolve(__dirname, 'template/'), '.', 'overwrite'); +// set correct project name on entry files if possible +var dirname = shell.ls('-d', 'ios/*.xcodeproj').stdout; +var projectName = dirname && dirname.slice( + 'ios/'.length, + dirname.length - '.xcodeproj'.length - 1 +); +if (projectName) { + shell.sed('-i', '%APP_NAME%', projectName, 'storybook/index.ios.js'); +} + var packageJson = helpers.getPackageJson(); // TODO: Get the latest version of storybook here. diff --git a/generators/REACT_NATIVE/template/storybook/index.ios.js b/generators/REACT_NATIVE/template/storybook/index.ios.js index a05f629f82a8..ce47e1723618 100644 --- a/generators/REACT_NATIVE/template/storybook/index.ios.js +++ b/generators/REACT_NATIVE/template/storybook/index.ios.js @@ -8,4 +8,4 @@ configure(() => { }, module); const StorybookUI = getStorybookUI({port: 7007, host: 'localhost'}); -AppRegistry.registerComponent('HelloWorld', () => StorybookUI); +AppRegistry.registerComponent('%APP_NAME%', () => StorybookUI);