mirror of
https://github.com/adobe/brackets.git
synced 2024-11-20 09:53:00 +01:00
adds check for main.js
This commit is contained in:
parent
2a6abc302c
commit
7b13bc0d8f
@ -59,6 +59,7 @@ function _cmdValidate(path, callback) {
|
||||
}
|
||||
var callbackCalled = false;
|
||||
var metadata;
|
||||
var foundMain = false;
|
||||
var errors = [];
|
||||
|
||||
fs.createReadStream(path)
|
||||
@ -109,6 +110,8 @@ function _cmdValidate(path, callback) {
|
||||
errors.push(["INVALID_VERSION_NUMBER", metadata.version, path]);
|
||||
}
|
||||
});
|
||||
} else if (fileName === "main.js") {
|
||||
foundMain = true;
|
||||
}
|
||||
})
|
||||
.on("end", function () {
|
||||
@ -120,6 +123,10 @@ function _cmdValidate(path, callback) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!foundMain) {
|
||||
errors.push(["MISSING_MAIN", path]);
|
||||
}
|
||||
|
||||
// No errors and no metadata means that we never found the metadata
|
||||
if (errors.length === 0 && !metadata) {
|
||||
callback(null, {
|
||||
|
@ -45,6 +45,7 @@ var basicValidExtension = path.join(testFilesDirectory, "basic-valid-extension.z
|
||||
invalidJSON = path.join(testFilesDirectory, "invalid-json.zip"),
|
||||
invalidZip = path.join(testFilesDirectory, "invalid-zip-file.zip"),
|
||||
missingNameVersion = path.join(testFilesDirectory, "missing-name-version.zip"),
|
||||
missingMain = path.join(testFilesDirectory, "missing-main.zip"),
|
||||
invalidVersion = path.join(testFilesDirectory, "invalid-version.zip");
|
||||
|
||||
describe("Package Validation", function () {
|
||||
@ -127,5 +128,14 @@ describe("Package Validation", function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it("should require a main.js in the zip file", function (done) {
|
||||
ExtensionsDomain._cmdValidate(missingMain, function (err, result) {
|
||||
expect(err).toBeNull();
|
||||
var errors = result.errors;
|
||||
expect(errors.length).toEqual(1);
|
||||
expect(errors[0][0]).toEqual("MISSING_MAIN");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
@ -314,6 +314,7 @@ define({
|
||||
"MISSING_PACKAGE_NAME" : "Missing package name in {0}",
|
||||
"MISSING_PACKAGE_VERSION" : "Missing package version in {0}",
|
||||
"INVALID_VERSION_NUMBER" : "Package version ({0}) is not a valid version number",
|
||||
"MISSING_MAIN" : "Package has no main.js file",
|
||||
|
||||
// extensions/default/InlineColorEditor
|
||||
"COLOR_EDITOR_CURRENT_COLOR_SWATCH_TIP" : "Current Color",
|
||||
|
BIN
test/spec/extension-test-files/missing-main.zip
Normal file
BIN
test/spec/extension-test-files/missing-main.zip
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user