Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement exercise versioning #688

Merged
merged 2 commits into from
Jun 13, 2019
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
2 changes: 1 addition & 1 deletion exercises/hello-world/hello-world.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { hello } from './hello-world';

describe('Hello World', () => {
test('says hello', () => {
test('Say Hi!', () => {
expect(hello()).toEqual('Hello, World!');
});
});
2 changes: 1 addition & 1 deletion exercises/hello-world/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "exercism-javascript",
"version": "0.0.0",
"version": "1.1.0",
"description": "Exercism exercises in Javascript.",
"author": "Katrina Owen",
"private": true,
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "exercism-javascript",
"version": "0.0.0",
"description": "Exercism exercises in Javascript.",
"author": "Katrina Owen",
"private": true,
Expand Down
10 changes: 9 additions & 1 deletion scripts/checksum
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ const crypto = require('crypto');

const sha = str => crypto.createHash('md5').update(str).digest("hex");

// Helper function to check single assignment
function checksum(filename, assignment, rootChecksum) {
if(!assignment) { return; }

const assignmentConfig = shell.cat(['exercises', assignment, filename].join('/')).toString();
let assignmentConfig = shell.cat(['exercises', assignment, filename].join('/')).toString();
if(filename === 'package.json') {
const json = JSON.parse(assignmentConfig);
delete json['version'];
assignmentConfig = JSON.stringify(json, null, 2) + '\n';
}
const assignmentChecksum = sha(assignmentConfig);

if(assignmentChecksum !== rootChecksum) {
Expand All @@ -27,6 +33,8 @@ function checksum(filename, assignment, rootChecksum) {
}
}

// Check all assignments by default
// or single if ASSIGNMENT is given
function checkSumAll(filename, rootFileName = filename) {
shell.echo('\nChecking integrity of ' + filename + '...');

Expand Down
1 change: 1 addition & 0 deletions scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function createExercisePackageJson() {
const packageFile = shell.cat('package.json').toString();
const packageJson = JSON.parse(packageFile);

delete packageJson['version'];
SKIP_PACKAGES_FOR_CHECKSUM.forEach(package => delete packageJson['devDependencies'][package]);

const shellStr = new shell.ShellString(JSON.stringify(packageJson, null, 2) + '\n');
Expand Down