Commit 54c3e1dd authored by Caleb C. Sander's avatar Caleb C. Sander
Browse files

Fix #2

parent 10b7e431
Showing with 21 additions and 8 deletions
+21 -8
......@@ -21,7 +21,7 @@ If you have a macOS or Linux machine, you should be able to download the CS 24 [
$ cd project05
# Build the interactive subpython interpreter
$ node ../make.js ../tests/cs24-project05.js subpython
$ npm run make ../tests/cs24-project05.js subpython
# Use the subpython interpreter
$ ./subpython -m 100000
......@@ -33,10 +33,10 @@ Using a memory size of 100000 bytes.
3
# Remove all built files
$ node ../make.js ../tests/cs24-project05.js clean
$ npm run make ../tests/cs24-project05.js clean
# Run the tests (they fail on the starter code)
$ node ../make.js ../tests/cs24-project05.js test
$ npm run make ../tests/cs24-project05.js test
```
If you don't have `clang` installed, you can change the C compiler to `gcc` at the top of the makefile.
If you've taken CS 24, try building and testing the completed version of the project!
......@@ -2,6 +2,10 @@ const {execFile} = require('child_process')
const path = require('path')
const {promisify} = require('util')
// If running as `npm run make`, use the current directory the command was run in
const {INIT_CWD} = process.env
if (INIT_CWD) process.chdir(INIT_CWD)
// A version of child_process.execFile() that returns a Promise
const exec = promisify(execFile)
/**
......@@ -22,7 +26,7 @@ function runCommand(command) {
}
const [recipesFile, ...targets] = process.argv.slice(2)
if (!recipesFile) throw new Error('Missing recipes file')
if (!recipesFile) throw new Error('Usage: npm run make makefile.js target1 ... targetN')
/* We get the exports from `recipesFile` using require().
* require() is blocking, but this is okay
......
......@@ -3,6 +3,7 @@
"version": "1.0.0",
"description": "CS 11 Asynchronous Programming - Make",
"scripts": {
"make": "node make.js",
"test": "ava --verbose tests/test-*.js"
},
"repository": {
......
......@@ -3,6 +3,8 @@ const path = require('path')
const test = require('ava')
const {execFilePromise, matchOutput} = require('./util')
// We are going to run the server directly, not through npm
const {INIT_CWD, ...MAKE_ENV} = process.env
process.chdir(__dirname)
async function make(dir, ...targets) {
......@@ -12,7 +14,7 @@ async function make(dir, ...targets) {
const {stdout} = await execFilePromise(
'node', ['../../make.js', '../concurrent-makefile.js', ...targets],
{cwd: path.join(__dirname, dir)}
{cwd: dir, env: MAKE_ENV}
)
return stdout
}
......
......@@ -4,6 +4,8 @@ const test = require('ava')
const {copyFiles, execFilePromise, matchOutput, wait} = require('./util')
const recipes = require('./dag-makefile')
// We are going to run the server directly, not through npm
const {INIT_CWD, ...MAKE_ENV} = process.env
process.chdir(__dirname)
const FILES_DIR = 'dag-files'
......@@ -24,7 +26,7 @@ function touch(file) {
async function makeDag(dir, ...targets) {
const {stdout} = await execFilePromise(
'node', ['../../make.js', '../dag-makefile.js', ...targets],
{cwd: path.resolve(__dirname, dir)}
{cwd: dir, env: MAKE_ENV}
)
return stdout
}
......
......@@ -3,6 +3,8 @@ const path = require('path')
const test = require('ava')
const {execFilePromise, matchOutput, wait} = require('./util')
// We are going to run the server directly, not through npm
const {INIT_CWD, ...MAKE_ENV} = process.env
process.chdir(__dirname)
async function makeC(dir) {
......@@ -16,7 +18,7 @@ async function makeC(dir) {
async function make(dir, ...targets) {
const {stdout} = await execFilePromise(
'node', ['../../make.js', '../special-cases-makefile.js', ...targets],
{cwd: path.resolve(__dirname, dir)}
{cwd: dir, env: MAKE_ENV}
)
return stdout
}
......
......@@ -4,6 +4,8 @@ const test = require('ava')
const {copyFiles, execFilePromise, matchOutput, wait} = require('./util')
const recipes = require('./tree-makefile')
// We are going to run the server directly, not through npm
const {INIT_CWD, ...MAKE_ENV} = process.env
process.chdir(__dirname)
const FILES_DIR = 'tree-files'
......@@ -170,7 +172,7 @@ const CHANGE_TESTS = [
async function makeTree(dir) {
const {stdout} = await execFilePromise(
'node', ['../../make.js', '../tree-makefile.js', ROOT_TARGET],
{cwd: path.resolve(__dirname, dir)}
{cwd: dir, env: MAKE_ENV}
)
return stdout
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment