From c98fc33ce5a2ddabeb9f0ffc939e76a68479f23b Mon Sep 17 00:00:00 2001 From: Hugo Dozois Date: Mon, 29 May 2017 12:36:11 -0700 Subject: [PATCH] Fix new-library to copy to current project Summary: - new-library was copying file inside the /node_modules/react-native/Libraries instead of /Libraries. This was due to the path.resolve that was being passed 2 full paths instead of a base path + relative path segment. --- Before: ```js console.log(libraryDest, dest, path.resolve(libraryDest, dest); // /Libraries/TestLib // /node_modules/react-native/Libraries/TestLib/package.json // /node_modules/react-native/Libraries/TestLib/package.json ``` After: ```js console.log(libraryDest, dest, path.resolve(libraryDest, dest); // /Libraries/TestLib // ../TestLib/package.json // /Libraries/TestLib/package.json ``` Closes https://github.com/facebook/react-native/pull/13748 Differential Revision: D5043652 Pulled By: shergin fbshipit-source-id: febee13781fc7075276daa67f9a78cc73dfd4b73 --- local-cli/library/library.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/local-cli/library/library.js b/local-cli/library/library.js index 3521c3305..6a8d36920 100644 --- a/local-cli/library/library.js +++ b/local-cli/library/library.js @@ -44,7 +44,7 @@ function library(argv, config, args) { return; } - const dest = f.replace(/Sample/g, args.name).replace(/^_/, '.'); + const dest = path.relative(source, f.replace(/Sample/g, args.name).replace(/^_/, '.')); copyAndReplace( path.resolve(source, f), path.resolve(libraryDest, dest),