Page 1 of 1
Switch scripting .sscript inflating pre-commit hook
Posted: Tue Aug 18, 2015 6:38 pm
by gabrielp
For anyone else finding it annoying that .sscript files are compressed and don't work well with version control applications (like Git), you might be manually unzipping your .sscript files and including them in your repositories.
An example of this would be:
https://github.com/dominickp/SwitchAWS. You can see I have a Packed and Unpacked directory and if you browse through the commit history in an Unpacked file (
https://github.com/dominickp/SwitchAWS/ ... ownload.js) you can see line by line changes, which is nice.
I've made a simple Git pre-commit "hook" which, once set up, will automatically scan through any .sscript files in your repo and unpack them whenever you make a new commit. It's pretty handy and can be found here:
https://gist.github.com/dominickp/97496d6cb8921ddc9d4a
Re: Switch scripting .sscript inflating pre-commit hook
Posted: Tue Aug 18, 2015 10:57 pm
by dkelly
nice. Do you have to add and commit again to get the Unpacked in repository?
Re: Switch scripting .sscript inflating pre-commit hook
Posted: Wed Aug 19, 2015 3:04 pm
by gabrielp
dkelly wrote:nice. Do you have to add and commit again to get the Unpacked in repository?
Yeah, you do. So you commit once, then immediately do another. Not sure what hook I could use that would prevent needing to do that

Re: Switch scripting .sscript inflating pre-commit hook
Posted: Thu Aug 20, 2015 10:35 am
by bens
A little-known fact is that Switch Scripter can actually work with unpacked sscript files. When you unzip an sscript, you get a folder with, among others, another sscript (of 0 bytes) inside it. If you open this second sscript in Switch Scripter you can edit the script as normal, and when you save it will save the unpacked script, perfect for source control! When you are ready to use or test the script in Switch simply use File - Save as..., which will create a packed sscript. Be careful not to overwrite the 0 byte sscript of course.
The normal way of working with sourcecontrol is to regard the packed sscript as output, and not commit it to the repository. In git you can add it to the .gitignore file.
Re: Switch scripting .sscript inflating pre-commit hook
Posted: Wed Sep 02, 2015 6:16 pm
by gabrielp
bens wrote:A little-known fact is that Switch Scripter can actually work with unpacked sscript files. When you unzip an sscript, you get a folder with, among others, another sscript (of 0 bytes) inside it. If you open this second sscript in Switch Scripter you can edit the script as normal, and when you save it will save the unpacked script, perfect for source control! When you are ready to use or test the script in Switch simply use File - Save as..., which will create a packed sscript. Be careful not to overwrite the 0 byte sscript of course.
The normal way of working with sourcecontrol is to regard the packed sscript as output, and not commit it to the repository. In git you can add it to the .gitignore file.
That's really good to know. But the one benefit I've found with adding the packed sscript file to your repo is that you can very easily update the production machine to master. I'll make a few updates on my development machine, merge the branch to master, then walk over to my production server and run a git pull on the repo and I'm done. I can now go into each flow and "reload" the script package and I've just updated each script. Keeping the packed file in the repo also makes it easy for people who might not be familiar with SwitchScripter to use your code.
Re: Switch scripting .sscript inflating pre-commit hook
Posted: Wed Oct 21, 2015 4:50 am
by gabrielp
Updated this so it now goes into subdirectories of a project:
https://gist.github.com/dominickp/97496d6cb8921ddc9d4a
Re: Switch scripting .sscript inflating pre-commit hook
Posted: Mon Nov 09, 2015 9:05 pm
by gabrielp
If you have trouble getting the hook to execute, try running this command from the repository directory:
Re: Switch scripting .sscript inflating pre-commit hook
Posted: Fri Dec 18, 2015 12:06 pm
by tz8
this is by the way amazing! Thank you for doing this!
Re: Switch scripting .sscript inflating pre-commit hook
Posted: Mon Sep 26, 2016 12:41 pm
by tz8
for the record: this stopped working in Switch 13 update 1, the unpacked scripts are now unreadable
Re: Switch scripting .sscript inflating pre-commit hook
Posted: Mon Sep 26, 2016 3:29 pm
by gabrielp
tz8 wrote:for the record: this stopped working in Switch 13 update 1, the unpacked scripts are now unreadable
Yeah. It's a huge annoyance. I've been copying a pasting my source code out into other files with every script revision because of it.
Re: Switch scripting .sscript inflating pre-commit hook
Posted: Tue Sep 27, 2016 5:18 pm
by tz8
Solution according to Enfocus is to keep developing in an old SwitchScripter 13 version. They implemented the encryption because of the introduction of the appstore.
I disagree to that solution. Your hacky solution is working but it just stays... hacky. Adding another step to the hackiness of the solution to get Switch scripts into GIT is just messy. Enfocus should implement one of the below:
- 'save as... encrypted script package'
- 'save as... raw code package'
- a flag in the preferences to also save as raw code in a directory next to the script
And i personally prefer Option 3, in our GIT solution we could then just ignore the .sscript and .sficture files and voilĂ we'd all be happy...