Fix new-library to copy to current project

Summary:
- new-library was copying file inside the <project_root>/node_modules/react-native/Libraries instead of <project_root>/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);

// <base-path>/Libraries/TestLib
// <base-path>/node_modules/react-native/Libraries/TestLib/package.json
// <base-path>/node_modules/react-native/Libraries/TestLib/package.json
```

After:

```js
console.log(libraryDest, dest, path.resolve(libraryDest, dest);

// <base-path>/Libraries/TestLib
// ../TestLib/package.json
// <base-path>/Libraries/TestLib/package.json
```
Closes https://github.com/facebook/react-native/pull/13748

Differential Revision: D5043652

Pulled By: shergin

fbshipit-source-id: febee13781fc7075276daa67f9a78cc73dfd4b73
This commit is contained in:
Hugo Dozois 2017-05-29 12:36:11 -07:00 committed by Facebook Github Bot
parent fff3ad1336
commit c98fc33ce5
1 changed files with 1 additions and 1 deletions

View File

@ -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),