MCPcopy Create free account
hub / github.com/PrairieLearn/PrairieLearn / writeAndCommitFileInLive

Function writeAndCommitFileInLive

tests/testFileEditor.js:756–785  ·  view source on GitHub ↗
(fileName, fileContents)

Source from the content-addressed store, hash-verified

754}
755
756function writeAndCommitFileInLive(fileName, fileContents) {
757 describe(`commit a change to ${fileName} by exec`, function() {
758 it('should write', function(callback) {
759 fs.writeFile(path.join(courseLiveDir, fileName), fileContents, (err) => {
760 if (ERR(err, callback)) return;
761 callback(null);
762 });
763 });
764 it('should add', function(callback) {
765 const execOptions = {
766 cwd: courseLiveDir,
767 env: process.env,
768 };
769 exec(`git add -A`, execOptions, (err) => {
770 if (ERR(err, callback)) return;
771 callback(null);
772 });
773 });
774 it('should commit', function(callback) {
775 const execOptions = {
776 cwd: courseLiveDir,
777 env: process.env,
778 };
779 exec(`git commit -m "commit from writeFile"`, execOptions, (err) => {
780 if (ERR(err, callback)) return;
781 callback(null);
782 });
783 });
784 });
785}
786
787function pullAndVerifyFileInDev(fileName, fileContents) {
788 describe(`pull in dev and verify contents of ${fileName}`, function() {

Callers 1

doEditsFunction · 0.85

Calls 2

itFunction · 0.85
callbackFunction · 0.85

Tested by

no test coverage detected