-
Notifications
You must be signed in to change notification settings - Fork 49
/
precommit.js
28 lines (23 loc) · 940 Bytes
/
precommit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env node
const path = require('path');
const fs = require('fs');
const DEFAULT_BUNDLE_IDENTIFIER = 'personal.bundle.identifier.MangaReader';
const PATTERN_PRODUCT_BUNDLE_IDENTIFIER = /PRODUCT_BUNDLE_IDENTIFIER = (.+);/g;
const revision = require('child_process')
.execSync('git diff --cached --name-only --diff-filter=ACM')
.toString()
.trim();
if (revision.includes('ios/MangaReader.xcodeproj/project.pbxproj')) {
const fileContent = fs
.readFileSync(path.resolve('ios/MangaReader.xcodeproj/project.pbxproj'))
.toString();
[...fileContent.matchAll(PATTERN_PRODUCT_BUNDLE_IDENTIFIER)].forEach((item) => {
const [, bundleIdentifier] = item || [];
if (
bundleIdentifier !== DEFAULT_BUNDLE_IDENTIFIER &&
bundleIdentifier !== '"org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"'
) {
throw new Error('开源项目请不要上传私人bundle identifier');
}
});
}