Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Tweaks for issue 97 #108

Merged
merged 1 commit into from

2 participants

@jonsharratt

Tweaks to the workings of @ryanramage to tidy up the settings file a little. Additionally have added some unit tests to ensure validity of package names.

@jonsharratt jonsharratt Work for issue #97
Tweaks to the workings of @ryanramage to tidy up the settings file a little. Additionally have added some unit tests to ensure validity of package names.
5a19891
@jonsharratt

Worth looking at how we can possibly capture the specific errors thrown within the unit tests as not sure how you can send the thrown error into the unit test from the forked process that runs the commands when testing.

@caolan
Owner

This looks great. Sorry it's taken me so long to get around to this pull request!

@caolan caolan merged commit 8e9aea8 into caolan:master
@caolan caolan referenced this pull request from a commit
@caolan test stderr for error messages in integration test for publishing pac…
…kages with invalid names, #108
5ebd2a0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 27, 2012
  1. @jonsharratt

    Work for issue #97

    jonsharratt authored
    Tweaks to the workings of @ryanramage to tidy up the settings file a little. Additionally have added some unit tests to ensure validity of package names.
This page is out of date. Refresh to see the latest.
View
5 lib/settings.js
@@ -24,10 +24,11 @@ exports.validate = function (settings, filename) {
if (!settings.name) {
throw new Error('Missing name property in ' + filename);
}
- if (!/^[a-zA-Z][a-zA-Z0-9_\-\.]*$/.test(settings.name)) {
+ if (!/^[a-zA-Z][a-zA-Z0-9_\-\.]*$/.test(settings.name) || (/\.js$/i).test(settings.name)) {
throw new Error(
- 'Invalid name property in ' + filename + ', ' +
+ 'Invalid name property in ' + filename + ', ' +
'package names can only contain numbers, upper or lowercase ' +
+ 'package name must not end with .js ' +
'letters and "_", "-" or ".", and must start with a letter'
);
}
View
3  test/integration/fixtures/package-three-invalid-characters/main.js
@@ -0,0 +1,3 @@
+deifne(['exports'], function (exports) {
+ exports.name = 'Package Three';
+});
View
5 test/integration/fixtures/package-three-invalid-characters/package.json
@@ -0,0 +1,5 @@
+{
+ "name": "package-@",
+ "version": "0.0.1",
+ "description": "Test package three"
+}
View
3  test/integration/fixtures/package-three-invalid-extjs/main.js
@@ -0,0 +1,3 @@
+deifne(['exports'], function (exports) {
+ exports.name = 'Package Three';
+});
View
5 test/integration/fixtures/package-three-invalid-extjs/package.json
@@ -0,0 +1,5 @@
+{
+ "name": "package-three.js",
+ "version": "0.0.1",
+ "description": "Test package three"
+}
View
18 test/integration/test-publish.js
@@ -88,3 +88,21 @@ exports['publish to command-line repo'] = function (test) {
});
});
};
+
+exports['publish with invalid .js package name'] = function (test) {
+ test.expect(1);
+ process.chdir('./fixtures/package-three-invalid-extjs');
+ utils.runJam(['publish'], {env: ENV}, function (err, stdout, stderr) {
+ test.ok(err);
+ test.done();
+ });
+};
+
+exports['publish with invalid package name characters'] = function (test) {
+ test.expect(1);
+ process.chdir('./fixtures/package-three-invalid-characters');
+ utils.runJam(['publish'], {env: ENV}, function (err, stdout, stderr) {
+ test.ok(err);
+ test.done();
+ });
+};
Something went wrong with that request. Please try again.