Skip to content

Commit e5c0a96

Browse files
author
Chris Brody
authored
refactoring: move require('uuid') out of templates (#261)
(templates/windows.js) rationale: it is desired to move templates/windows.js into an "unsupported" directory tree, and then test it with a mock using uuid from devDependencies, in the near future
1 parent 18e3a10 commit e5c0a96

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

lib/lib.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const fsExtra = require('fs-extra');
1212

1313
const jsonfile = require('jsonfile');
1414

15+
const uuidV1 = require('uuid').v1;
16+
1517
// Internal imports:
1618

1719
const normalizedOptions = require('./normalized-options');
@@ -151,6 +153,11 @@ const generateWithNormalizedOptions = ({
151153

152154
console.info('CREATE: Generating the React Native library module');
153155

156+
// uuid (v1) for Windows only for now (at least)
157+
const uuid = (platforms.indexOf('windows') !== -1)
158+
? uuidV1().toUpperCase()
159+
: null;
160+
154161
const generateLibraryModule = () => {
155162
return fs.ensureDir(moduleName).then(() => {
156163
return Promise.all(templates.filter((template) => {
@@ -173,6 +180,7 @@ const generateWithNormalizedOptions = ({
173180
license,
174181
view,
175182
useAppleNetworking,
183+
uuid,
176184
generateExample,
177185
exampleName,
178186
};

templates/windows.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
const uuid = require('uuid').v1().toUpperCase();
2-
31
module.exports = platform => [{
42
name: ({ name }) => `${platform}/${name}.sln`,
5-
content: ({ name }) =>
3+
content: ({ name, uuid }) =>
64
`Microsoft Visual Studio Solution File, Format Version 12.00
75
# Visual Studio 14
86
VisualStudioVersion = 14.0.25123.0
@@ -209,7 +207,7 @@ obj/
209207
`,
210208
}, {
211209
name: ({ name }) => `${platform}/${name}/${name}.csproj`,
212-
content: ({ name, namespace }) =>
210+
content: ({ name, namespace, uuid }) =>
213211
`<?xml version="1.0" encoding="utf-8"?>
214212
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
215213
<Import Project="$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')" />

tests/with-mocks/cli/command/func/with-logging/with-error/__snapshots__/cli-command-with-logging-with-error.test.js.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ Array [
4545
"error": Array [
4646
"Error: ENOPERM not permitted
4747
at Object.ensureDir (.../tests/with-mocks/cli/command/func/with-logging/with-error/cli-command-with-logging-with-error.test.js:9:27)
48-
at ensureDir (.../lib/lib.js:155:15)
49-
at generateLibraryModule (.../lib/lib.js:281:10)
50-
at generateWithNormalizedOptions (.../lib/lib.js:298:10)
48+
at ensureDir (.../lib/lib.js:162:15)
49+
at generateLibraryModule (.../lib/lib.js:289:10)
50+
at generateWithNormalizedOptions (.../lib/lib.js:306:10)
5151
at createLibraryModule (.../lib/cli-command.js:...
5252
at Object.func (.../tests/with-mocks/cli/command/func/with-logging/with-error/cli-command-with-logging-with-error.test.js:62:9)
5353
",

0 commit comments

Comments
 (0)