Skip to content

Commit

Permalink
Merge pull request #3554 from peircej/hotfix-JSboilerplateVersion
Browse files Browse the repository at this point in the history
RF: moving to 3-part semantic versions for JS
  • Loading branch information
peircej committed Feb 10, 2021
2 parents 56400cd + 0b80bb1 commit 470cea8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion psychopy/experiment/_experiment.py
Expand Up @@ -208,10 +208,10 @@ def writeScript(self, expPath=None, target="PsychoPy", modular=True):
self_copy.flow.writeBody(script)
self_copy.settings.writeEndCode(script) # close log file
script = script.getvalue()

elif target == "PsychoJS":
script.oneIndent = " " # use 2 spaces rather than python 4


self_copy.settings.writeInitCodeJS(script,self_copy.psychopyVersion,
localDateTime, modular)

Expand Down
21 changes: 13 additions & 8 deletions psychopy/experiment/components/settings/__init__.py
Expand Up @@ -531,15 +531,20 @@ def writeInitCodeJS(self, buff, version, localDateTime, modular=True):
# decide if we need anchored useVersion or leave plain
useVer = self.params['Use version'].val
if useVer == '':
useVer = '.'.join(version.split('.')[:2])
useVer = version
elif useVer == 'latest':
useVer = '.'.join(latestVersion().split('.')[:2])
else:
# do we shorten minor versions ('3.4.2' to '3.4')?
# only from 3.2 onwards
if (parse_version(useVer) > (parse_version('3.2'))
and len(useVer.split('.'))>2):
useVer = '.'.join(useVer.split('.')[:2])
useVer = latestVersion()

# do we shorten minor versions ('3.4.2' to '3.4')?
# only from 3.2 onwards
if (parse_version('3.2')) <= parse_version(useVer) < parse_version('2021') \
and len(useVer.split('.')) > 2:
# e.g. 2020.2 not 2021.2.5
useVer = '.'.join(useVer.split('.')[:2])
elif len(useVer.split('.')) > 3:
# e.g. 2021.1.0 not 2021.1.0.dev3
useVer = '.'.join(useVer.split('.')[:3])

# prepend the hyphen
versionStr = '-{}'.format(useVer)

Expand Down

0 comments on commit 470cea8

Please sign in to comment.