Include non-electron folder as part of the NSIS installation - electron

I've been trying to add additional functionality to the electron installer, where I copy some files that are packaged inside the installer, but I receive a non-descriptive error when I try to compile my electron project to create the installer i.e. I get:
* writing effective config
* packaging
* building
x [object Object]
Here is what my script looks like:
!macro customInstall
Rename "$APPDATA\myfolder\img" "$APPDATA\myfolder\img-old"
SetOutPath "$APPDATA\myfolder"
File /nonfatal /a /r "additional_files\*"
CreateShortcut "$SMSTARTUP\mylink.lnk" "$INSTDIR\mylink.exe"
!macroend
Basically everything works except the file copy part. When I remove that part the project builds and compiles into an installer with no problems.
I've also tried to use CopyFiles instead of SetOutPath and File and it works as expected when I place the additional_files folder into the same folder as the installation (dist folder), but I want the folder to be packaged inside the installer. However, I cannot get the additional_files to be packaged with the installation.
I believe it's a location issue, that is, that the NSIS script cannot locate the additional_files/ folder. I've tried modifying the package.json file by adding to the files section the additional_files/ folder and placing it in the root of the project.
I've even tried placing it in the build folder where my installer.nsh script resides, but with no luck.

File looks for files relative to the directory where the .nsi is by default. /NOCD can be used to prevent that but I'm not sure if electron uses that switch.
!cd can be used inside a script to change the directory but I'm not sure if that is going to help you much in this case unless you are willing to use a absolute path and in that case you could just use the absolute path with the File instruction instead.
If you only know where your .nsh file is I suppose you could try File /r "${__FILEDIR__}\additional_files\*"

if you are using electron-builder you have two options inside the settings
extraResources this will copy files into the $INST_DIR/resources folder in your app (this is where the app.asar file is too), and you can access via process.resourcesPath, ex:
extraResources: [
{ from: './dist/ThirdPartyNotices.txt', to: 'ThirdPartyNotices.txt' },
]
extraFiles this would do the same but place the files into the $INST_DIR root folder of your installation ex:
extraFiles: [
{ from: './distrib/mytool.exe', to: 'mytool.exe' },
],
to get the root folder you can use something like remote.app.getAppPath().replace('resources\\app.asar', '').replace('resources/app.asar', '');
all info on: https://www.electron.build/configuration/configuration#overridable-per-platform-options

Related

Writing to a packaged app folder in Electron

I'm creating a portable Electron app that writes some files to the program folder. It works pretty well when I package it without the --asar option in Electron-packager, which leaves the resources folder with plain html + js files.
Now when I try to compile it with the --asar option, so that it packages the resources folder into one file, I can't access the program directory any more with the following code:
remote.app.getAppPath()
This now returns the path of the asar file, so I can't really write to the application folder any more. Is there any way around this?
No, you cannot modify the asar of a running Electron app. You should be saving your config outside of the asar path.

yeoman creates project in Desktop even though I CD into directory

I am having a issue creating a yeoman project. I cd in the directory type yo and it says:
Here is it suppose to asked me project name etc and it wants to throw everything on my desktop not the file I cd into. It defaults to mvn and I want gradle. I even npm uninstall -g generator-jhipster
and reinstalled it and got the same issue.
If you have a .yo-rc.json file in a parent directory, Yeoman will load that configuration and generate from that file instead of prompting. This allows developers to run a yo command from any folder in the project and have it apply to the correct files.
To solve this, remove the .yo-rc.json from the parent directory, in your case /Users/drew/Desktop.
For example, if you are in the directory /Users/drew/Desktop/new-project but /Users/drew/Desktop has a .yo-rc.json inside, Yeoman will change to the parent directory (Desktop), load the configuration, and generate the files from that folder instead of the child folder.
Based on your log it's looks like you are running yo in a folder where a .yo-rc.json is already existing. Careful under windows the .yo-rc.json can be that is of type hidden and you can't see it in explorer. Because of an existing .yo-rc.json you are not asked anymore for info e.g. project name, build tool etc. My recommendation will be to create a new folder run inside yo command

Permanently add bower proxy

How do I permanently add bower proxy to my system so I do not have to edit the .bowerrc file for every project and add
{
"proxy":"http://<proxy>:<port>",
"https-proxy":"https://<proxy>:<port>",
}
I have added the proxys to my OS with:
export HTTP_PROXY=http://<proxy_url>:<port>
export HTTPS_PROXY=http://<proxy_url>:<port>
But it seams bower does not get it. Thank you in advance for your response
Put the .bowerrc file in your home folder (it will work on Windows as well).
From http://bower.io/docs/config/:
Placement & Order
The config is obtained by merging multiple configurations by this
order of importance:
CLI arguments via --config
Environment variables
Local .bowerrc located in the current working directory
All .bowerrc files upwards the directory tree
.bowerrc file located in user’s home folder (~)
.bowerrc file located in the global folder (/)
Example of CLI arguments:
--config.endpoint-parser=
--config.storage.cache=
Example of valid environment variables:
bower_endpoint_parser is evaluated as endpoint-parser
bower_storage__cache is evaluated as storage.cache

using "packages" folder in DART

In my app, I've the pubspec.yaml file as:
name: server
dependencies:
oracledart: any
and after running pub get, I got the folder "packages" updated correctly.
I wanted to create sub folders for testing my functions individually, so I created folder: test/boms.dart, which is:
import 'dart:async';
import 'package:oracledart/oracledart.dart';
void main() {
...
}
but once running it, I got this error msg:
Unhandled exception:
Uncaught Error: FileSystemException: Cannot open file, path = 'G:\app\bin\test\packages\oracledart\oracledart.dart' (OS Error: The system cannot find the path specified.
Do I need to copy the 'packages' folder to each sub folder have the function "main", or there is another way to connect it!
At least for top-level folders the packages link should be created automatically. Try run pub get or pub upgrade or create the test folder from within DartEditor (I don't know what creates the symlinks but usually they are created automatically in top-level folders as far as I remember). In subfolders of top-level folders like bin, test, ... I always had to create them manually by creating a new symlink to the packages link in the package root.
In Linux like:
ln -s ../packages/ packages
don't know how to in Windows.
I think the DART team, should make symlinks auto generation in sub folders of the "bin" folder, same as the case of the sub folders of the "web" folder.
anyhow, to create them manually in Windows 7, I found it make as below:
1. run CMD as admin
2. mklink /D myApp\bin\test\packages myApp\packages [D for directory, not drive]
I found how to make symlinks in windows here
another full detailed way is mentioned here

Sublime 2 can not find file in the path (LaTeX plugin)

I have a project in directory A and files that I use in all my projects are in directory B.
When I moved a .sty file from A to B, the main .tex file does not compile anymore.
The error is that the .sty file was not found. I am puzzled because:
Directory B is included in the path of the project.
I cleaned (deleted manually) all the auxiliary files used in the previous compilations.
I refreshed the project folders .
Did anyone had similar problems? Suggestions?
The file LaTeX.sublime-build, within the Sublime Text folder . . . /Packages/LaTeXTools, contains a $PATH for different operating systems.
For example, Sublime Text 2 on an OSX operating system, has a file located at ~/Library/Application Support/Sublime Text 2/Packages/LaTeXTools/LaTeX.sublime-build. The relevant line of code for a MacTeX TexLive 2012 installation is "path": "$PATH:/usr/texbin:/usr/local/bin",. The plugin LaTeXTools looks in that path for *.sty files that are a part of the TexLive installation. While it may be possible (under some circumstances) to place the *.sty files within the working directory of the *.tex file, this particular plugin looks to the path mentioned hereinabove. So one option would be to add additional locations to the $PATH to suit the needs of the user, or simply place the *.sty files within the path that is pre-defined by the plugin developer.

Resources