Skip to content

Commit

Permalink
fixed incorrect assumption about relative paths
Browse files Browse the repository at this point in the history
  • Loading branch information
dblanchardDev committed Mar 13, 2020
1 parent 6fd21fb commit 028654d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions jinjasqltranspiler/jinjasqltranspiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def transpile_project(self):

# OPTIONS -------------------------------------------------------------------------------------
@staticmethod
def set_options(templates_dir=None, transpiled_dir=None, debug_dir=None, ansi_nulls=None, quoted_id=None, skip_prefixes=None):
def set_options(workspace, templates_dir=None, transpiled_dir=None, debug_dir=None, ansi_nulls=None, quoted_id=None, skip_prefixes=None):
"""Set the user defined options used by the transpiler.
Args:
Expand Down Expand Up @@ -236,7 +236,8 @@ def set_options(templates_dir=None, transpiled_dir=None, debug_dir=None, ansi_nu

# Write to file
options_json = json.dumps(options)
with open(JinjaSQLTranspiler.OPTION_FILE, "w", encoding="utf-8") as optFile:
options_path = os.path.join(workspace, JinjaSQLTranspiler.OPTION_FILE)
with open(options_path, "w", encoding="utf-8") as optFile:
optFile.write(options_json)

# Completed Message
Expand All @@ -263,7 +264,8 @@ def get_options(self):
options = None

# If a file exists, use those
if os.path.isfile(self.OPTION_FILE):
options_path = os.path.join(self._workspace_dir, self.OPTION_FILE)
if os.path.isfile(options_path):
with open(self.OPTION_FILE, "r", encoding="utf-8") as optFile:
options = json.loads(optFile.read())

Expand Down Expand Up @@ -517,6 +519,7 @@ def _parse_arguments():
nulls_help = "Whether to explicitly enable ANSI Nulls in transpiled code."
quoted_help = "Whether to explicitly enable QUOTED IDENTEFIERS in transpiled code."

option_parser.add_argument(dest="workspace", help="The absolute path to the VS Code project workspace.")
option_parser.add_argument("-t", dest="templates_dir", help="Path to the directory containing the project's templates.")
option_parser.add_argument("-p", dest="transpiled_dir", help="Path to the directory where transpiled files will be output.")
option_parser.add_argument("-d", dest="debug_dir", help="Path to the directory where debuging files will be output.")
Expand Down
4 changes: 3 additions & 1 deletion tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"args": [
"jinjasqltranspiler\\jinjasqltranspiler.py",
"set_options",
"${workspaceFolder}",
"-t", "${input:jst_templates_dir}",
"-p", "${input:jst_transpiled_dir}",
"-d", "${input:jst_debug_dir}",
Expand Down Expand Up @@ -77,7 +78,8 @@
"command": "${config:python.pythonPath}",
"args": [
"jinjasqltranspiler\\jinjasqltranspiler.py",
"parameter_presets"
"parameter_presets",
"${workspaceFolder}"
],
"presentation": {
"reveal": "always",
Expand Down

0 comments on commit 028654d

Please sign in to comment.