mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
Create journal with absolute path when no path is specified (#972)
* create jrnl with abspath Co-authored-by: = <esrh@netc.eu>
This commit is contained in:
parent
d9951b54c0
commit
2a3fd820b9
4 changed files with 21 additions and 2 deletions
|
@ -119,3 +119,14 @@ Feature: Basic reading and writing to a journal
|
|||
When we run "jrnl Life is good"
|
||||
and we run "jrnl -n 1"
|
||||
Then the output should contain "Life is good"
|
||||
|
||||
Scenario: Installation with relative journal and referencing from another folder
|
||||
Given we use the config "missingconfig"
|
||||
When we run "jrnl hello world" and enter
|
||||
"""
|
||||
test.txt
|
||||
n
|
||||
"""
|
||||
and we change directory to "features"
|
||||
and we run "jrnl -n 1"
|
||||
Then the output should contain "hello world"
|
||||
|
|
|
@ -2,6 +2,8 @@ import os
|
|||
import shutil
|
||||
import sys
|
||||
|
||||
CWD = os.getcwd()
|
||||
|
||||
|
||||
def clean_all_working_dirs():
|
||||
for folder in ("configs", "journals", "cache"):
|
||||
|
@ -26,7 +28,6 @@ def before_scenario(context, scenario):
|
|||
"""Before each scenario, backup all config and journal test data."""
|
||||
# Clean up in case something went wrong
|
||||
clean_all_working_dirs()
|
||||
|
||||
for folder in ("configs", "journals"):
|
||||
original = os.path.join("features", "data", folder)
|
||||
working_dir = os.path.join("features", folder)
|
||||
|
@ -52,4 +53,6 @@ def before_scenario(context, scenario):
|
|||
|
||||
def after_scenario(context, scenario):
|
||||
"""After each scenario, restore all test data and remove working_dirs."""
|
||||
if os.getcwd() != CWD:
|
||||
os.chdir(CWD)
|
||||
clean_all_working_dirs()
|
||||
|
|
|
@ -96,6 +96,11 @@ def set_config(context, config_file):
|
|||
cf.write("version: {}".format(__version__))
|
||||
|
||||
|
||||
@when('we change directory to "{path}"')
|
||||
def move_up_dir(context, path):
|
||||
os.chdir(path)
|
||||
|
||||
|
||||
@when('we open the editor and enter "{text}"')
|
||||
@when("we open the editor and enter nothing")
|
||||
def open_editor_and_enter(context, text=""):
|
||||
|
|
|
@ -135,7 +135,7 @@ def install():
|
|||
|
||||
# Where to create the journal?
|
||||
path_query = f"Path to your journal file (leave blank for {JOURNAL_FILE_PATH}): "
|
||||
journal_path = input(path_query).strip() or JOURNAL_FILE_PATH
|
||||
journal_path = os.path.abspath(input(path_query).strip() or JOURNAL_FILE_PATH)
|
||||
default_config["journals"][DEFAULT_JOURNAL_KEY] = os.path.expanduser(
|
||||
os.path.expandvars(journal_path)
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue