Skip to content

Commit 4db12ce

Browse files
committed
Dist now copies package.json fields to Unity dist
1 parent bbebeaa commit 4db12ce

File tree

3 files changed

+7161
-129
lines changed

3 files changed

+7161
-129
lines changed

Assets/FluidBehaviorTree/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
{
22
"name": "com.fluid.behavior-tree",
3-
"version": "0.0.0",
3+
"version": "1.0.0",
44
"displayName": "Fluid Behavior Tree",
55
"description": "A micro-framework for creating Behavior Trees based upon the builder pattern",
66
"unity": "2018.1",
7-
"dependencies": {
8-
},
97
"keywords": [
108
"ai",
119
"behavior tree",
@@ -24,5 +22,6 @@
2422
"bugs": {
2523
"url": "https://github.com/ashblue/fluid-behavior-tree/issues"
2624
},
27-
"homepage": "https://github.com/ashblue/fluid-behavior-tree#readme"
25+
"homepage": "https://github.com/ashblue/fluid-behavior-tree#readme",
26+
"dependencies": {}
2827
}

create-dist.js

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ async function init () {
1414
await del([OUTPUT]);
1515

1616
copyFiles();
17-
updateVersionNumber();
17+
crossPopulatePackages();
18+
fs.copyFileSync(`${SOURCE}/package.json`, `${OUTPUT}/package.json`);
1819
}
1920

2021
function copyFiles() {
@@ -25,11 +26,31 @@ function copyFiles() {
2526
});
2627
}
2728

28-
function updateVersionNumber() {
29-
const npmPackage = JSON.parse(fs.readFileSync('package.json').toString());
30-
const unityPackage = JSON.parse(fs.readFileSync(`${SOURCE}/package.json`).toString());
31-
unityPackage.version = npmPackage.version;
32-
fs.writeFileSync(`${OUTPUT}/package.json`, JSON.stringify(unityPackage, null, 2));
29+
function crossPopulatePackages() {
30+
copyJsonFields('package.json', `${SOURCE}/package.json`, [
31+
'name',
32+
'displayName',
33+
'description',
34+
'version',
35+
'unity',
36+
'repository',
37+
'license',
38+
'bugs',
39+
'homepage',
40+
'keywords',
41+
'author',
42+
]);
43+
}
44+
45+
function copyJsonFields(sourcePath, destPath, fields) {
46+
const source = JSON.parse(fs.readFileSync(sourcePath).toString());
47+
const dest = JSON.parse(fs.readFileSync(destPath).toString());
48+
49+
fields.forEach((field) => {
50+
dest[field] = source[field];
51+
});
52+
53+
fs.writeFileSync(destPath, JSON.stringify(dest, null, 2));
3354
}
3455

3556
init();

0 commit comments

Comments
 (0)