Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Latest commit

 

History

History
History
executable file
·
104 lines (83 loc) · 2.99 KB

File metadata and controls

executable file
·
104 lines (83 loc) · 2.99 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env node
console.error("The ns-verify-bundle script is deprecated!")
const path = require("path");
const fs = require("fs");
const { getProjectDir } = require("../projectHelpers");
const PROJECT_DIR = getProjectDir();
const APP_ID = require(path.resolve(PROJECT_DIR, "./package.json")).nativescript.id;
const APP_NAME = APP_ID.substring(APP_ID.lastIndexOf(".") + 1);
const PROJECT_PATHS = {
android: path.resolve(PROJECT_DIR, "platforms/android/src/main/assets/app"),
ios: path.resolve(PROJECT_DIR, `platforms/ios/build/emulator/${APP_NAME}.app/app`),
};
const npmArgs = JSON.parse(process.env.npm_config_argv).original;
const flags = npmArgs.filter(a => a.startsWith("--")).map(a => a.substring(2));
const file = getTargetFile(flags);
const platform = getPlatform(flags);
const filePath = path.resolve(PROJECT_PATHS[platform], file);
console.log(`Checking ${filePath} exists`);
if (!fs.existsSync(filePath)) {
throwError({message: `${filePath} doesn not exist!`});
}
const maxSize = getMaxSize(flags);
if (maxSize) {
checkFileSizeIsUnder(filePath, maxSize).then().catch(throwError);
}
function getTargetFile(flags) {
let fileFlags = flags.filter(f => f.startsWith("file="));
if (fileFlags.length != 1) {
throwError({message: "You must provide a target file!"});
}
fileFlags = fileFlags[0];
return fileFlags.substring(fileFlags.indexOf("=") + 1);
}
function getMaxSize(flags) {
let sizeFlags = flags.filter(f => f.startsWith("maxSize="));
if (sizeFlags.length == 0) {
return;
} else if (sizeFlags.length > 1) {
throwError({message: "You must provide 0 or 1 maxSize flags!"});
}
sizeFlags = sizeFlags[0];
return sizeFlags.substring(sizeFlags.indexOf("=") + 1);
}
function getPlatform(flags) {
if (flags.includes("android") && flags.includes("ios")) {
throwError({message: "You cannot use both --android and --ios flags!"});
}
if (flags.includes("android")) {
return "android";
} else if (flags.includes("ios")) {
return "ios";
} else {
throwError({message: "You must provide a target platform! Use either --android, or --ios flag."});
}
}
function checkFileSizeIsUnder(fileName, sizeInBytes) {
console.log(`Checking ${fileName} size is under ${sizeInBytes}`);
return new Promise((resolve, reject) => {
readFile(fileName)
.then(content => {
if (content.length <= sizeInBytes) {
resolve();
} else {
reject({message: `File "${fileName}" exceeded file size of "${sizeInBytes}".`});
}
});
});
}
function readFile(fileName) {
return new Promise((resolve, reject) => {
fs.readFile(fileName, "utf-8", (err, data) => {
if (err) {
reject(err);
} else {
resolve(data);
}
});
});
}
function throwError(error) {
console.error(error.message);
process.exit(error.code || 1);
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.