Skip to content

Commit 253b245

Browse files
committed
Merge pull request #492 from dnephin/project_name_from_env
Support setting project name from the environment
2 parents 92ae5af + fac49b6 commit 253b245

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

fig/cli/command.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def get_project_name(self, config_path, project_name=None):
8181
def normalize_name(name):
8282
return re.sub(r'[^a-zA-Z0-9]', '', name)
8383

84+
project_name = project_name or os.environ.get('FIG_PROJECT_NAME')
8485
if project_name is not None:
8586
return normalize_name(project_name)
8687

tests/unit/cli_test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ def test_project_name_with_explicit_project_name(self):
3535
project_name = command.get_project_name(None, project_name=name)
3636
self.assertEquals('explicitprojectname', project_name)
3737

38+
def test_project_name_from_environment(self):
39+
command = TopLevelCommand()
40+
name = 'namefromenv'
41+
with mock.patch.dict(os.environ):
42+
os.environ['FIG_PROJECT_NAME'] = name
43+
project_name = command.get_project_name(None)
44+
self.assertEquals(project_name, name)
45+
3846
def test_yaml_filename_check(self):
3947
command = TopLevelCommand()
4048
command.base_dir = 'tests/fixtures/longer-filename-figfile'

0 commit comments

Comments
 (0)