Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit 4633b95

Browse files
committed
Make serve and build find the project root.
1 parent 6346d48 commit 4633b95

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

runestone/__main__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ def init():
4242

4343
def build():
4444
from paver.tasks import main as paver_main
45+
os.chdir(findProjectRoot())
4546
sys.argv[0] = "build"
4647
paver_main()
4748

4849
def serve():
50+
os.chdir(findProjectRoot())
4951
sys.path.insert(0,os.getcwd())
5052
try:
5153
import pavement
@@ -76,7 +78,7 @@ def main(args=None):
7678
args = sys.argv[1:]
7779
foo_config = resource_filename('runestone', 'common')
7880
# foo_string = resource_string('runestone', 'project/template/conf.tmpl')
79-
print(findProjectRoot())
81+
8082
if args[0] == "init":
8183
init()
8284
elif args[0] == "build":
@@ -88,11 +90,13 @@ def main(args=None):
8890

8991
def findProjectRoot():
9092
start = os.getcwd()
91-
done = False
92-
while start != "/":
93+
prevdir = ""
94+
while start != prevdir:
9395
if os.path.exists(os.path.join(start,'pavement.py')):
9496
return start
97+
prevdir = start
9598
start = os.path.dirname(start)
99+
raise NotADirectoryError("You must be in a runestone project to run runestone")
96100

97101
if __name__ == "__main__":
98102
sys.exit(main(sys.argv[1:]))

0 commit comments

Comments
 (0)