Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Remove main.js requirement for themes #9434

Merged
merged 1 commit into from
Oct 9, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/extensibility/node/package-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,11 @@ function extractAndValidateFiles(zipPath, extractDir, options, callback) {
callback(err, null);
return;
}
var mainJS = path.join(extractDir, commonPrefix, "main.js");
if (!fs.existsSync(mainJS)) {
var mainJS = path.join(extractDir, commonPrefix, "main.js"),
isTheme = metadata && metadata.theme;

// Throw missing main.js file only for non-theme extensions
if (!isTheme && !fs.existsSync(mainJS)) {
errors.push([Errors.MISSING_MAIN, zipPath, mainJS]);
}
callback(null, {
Expand Down
2 changes: 1 addition & 1 deletion src/extensibility/node/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "brackets-extensibility",
"description": "Used in the management of Brackets extensions",
"version": "0.32.0",
"version": "0.45.0",
"dependencies": {
"decompress-zip": "0.0.2",
"semver": "2.x",
Expand Down
2 changes: 1 addition & 1 deletion src/extensibility/node/spec/Installation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ var basicValidExtension = path.join(testFilesDirectory, "basic-valid-exten
missingPackageJSON = path.join(testFilesDirectory, "missing-package-json.zip"),
missingPackageJSONUpdate = path.join(testFilesDirectory, "missing-package-json-update.zip"),
missingPackageJSONRenamed = path.join(testFilesDirectory, "added-package-json-test", "missing-package-json.zip"),
withSymlink = path.join(testFilesDirectory, "with-symlink.zip");
withSymlink = path.join(testFilesDirectory, "with-symlink.zip");


describe("Package Installation", function () {
Expand Down
10 changes: 10 additions & 0 deletions src/extensibility/node/spec/Validation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var testFilesDirectory = path.join(path.dirname(module.filename),

var basicValidExtension = path.join(testFilesDirectory, "basic-valid-extension.zip"),
basicValidExtension2 = path.join(testFilesDirectory, "basic-valid-extension-2.0.zip"),
basicValidTheme = path.join(testFilesDirectory, "basic-valid-theme-1.0.zip"),
missingPackageJSON = path.join(testFilesDirectory, "missing-package-json.zip"),
invalidJSON = path.join(testFilesDirectory, "invalid-json.zip"),
invalidZip = path.join(testFilesDirectory, "invalid-zip-file.zip"),
Expand Down Expand Up @@ -167,6 +168,15 @@ describe("Package Validation", function () {
});
});

it("should NOT require a main.js in the zip file for a theme", function (done) {
packageValidator.validate(basicValidTheme, {}, function (err, result) {
expect(err).toBeNull();
expect(result.errors.length).toEqual(0);
expect(result.metadata.theme).toBeDefined();
done();
});
});

it("should determine the common prefix if there is one", function (done) {
packageValidator.validate(oneLevelDown, {}, function (err, result) {
expect(err).toBeNull();
Expand Down
Binary file not shown.
19 changes: 19 additions & 0 deletions test/spec/extension-test-files/basic-valid-theme-1.0/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "basic-valid-theme",
"title": "Basic Valid Theme",
"version": "1.0.0",
"author": "Alfred Einstein <[email protected]> (http://thoseeinsteins.org/alfred)",
"contributors": [
"Johan Einstein",
{
"name": "Albert Einstein Jr.",
"email": "[email protected]"
},
"Jens Einstein <[email protected]>"
],
"theme": {
"file": "theme.less",
"dark": false
},
"keywords": ["theme"]
}