lib/utilities/windows-admin.js:7

WindowsSymlinkChecker

On windows users will have a much better experience if symlinks are enabled an usable. This object when queried informs windows users, if they can improve there build performance, and how.

Windows vista: nothing we can really do, so we fall back to junctions for folders + copying of files <= Windows vista: symlinks are available but using them is somewhat tricky * if the users is an admin, the process needed to have been started with elevated privs * if the user is not an admin, a specific setting needs to be enabled <= Windows 10 Insiders build 14972 * if developer mode is enabled, symlinks "just work" * https://blogs.windows.com/buildingapps/2016/12/02/symlinks-windows-10

 let checker = WindowsSymlinkChecker;
 let {
   windows,
   elevated
 } = await = checker.checkIfSymlinksNeedToBeEnabled(); // aslso emits helpful warnings

Method Summary

Public Methods
public
public
checkIfSymlinksNeedToBeEnabled( ): Promise

if not windows, will fulfill with: { windows: false, elevated: null) if windows, and elevated will fulfill with: { windows: false, elevated: true) if windows, and is NOT elevated will fulfill with: { windows: false, elevated: false) will include heplful warning, so that users know (if possible) how to achieve better windows build performance

public
insertIntoFile(pathRelativeToProjectRoot, contentsToInsert, providedOptions): Promise

Inserts the given content into a file. If the contentsToInsert string is already present in the current contents, the file will not be changed unless force option is passed.

public

Sets up listeners for interruption signals

public

Removes interruption signal listeners and tears down capture-exit

public

Suppresses "Terminate batch job (Y/N)" confirmation on Windows

Private Methods
private

Uses the eon-old command NET SESSION to determine whether or not the current user has elevated rights (think sudo, but Windows).

private

sets up a WindowsSymlinkChecker

private

Add process interruption handler

private

Exit silently

private

Exit silently

private
release( )

Drops all the interruption handlers and disables an ability to add new one

private

Remove process interruption handler

Public Methods

lib/utilities/windows-admin.js:83

public checkIfSymlinksNeedToBeEnabled( ): Promise

Return:

Promise

Object describing whether we're on windows and if admin rights exist

lib/utilities/windows-admin.js:39

public checkIfSymlinksNeedToBeEnabled( ): Promise

if not windows, will fulfill with: { windows: false, elevated: null) if windows, and elevated will fulfill with: { windows: false, elevated: true) if windows, and is NOT elevated will fulfill with: { windows: false, elevated: false) will include heplful warning, so that users know (if possible) how to achieve better windows build performance

Return:

Promise

Object describing whether we're on windows and if admin rights exist

lib/utilities/insert-into-file.js:11

public insertIntoFile(pathRelativeToProjectRoot, contentsToInsert, providedOptions): Promise

Inserts the given content into a file. If the contentsToInsert string is already present in the current contents, the file will not be changed unless force option is passed.

If options.before is specified, contentsToInsert will be inserted before the first instance of that string. If options.after is specified, the contents will be inserted after the first instance of that string. If the string specified by options.before or options.after is not in the file, no change will be made.

If neither options.before nor options.after are present, contentsToInsert will be inserted at the end of the file.

Example:

// app/router.js
Router.map(function() {
});
insertIntoFile('app/router.js', '  this.route("admin");', {
  after: 'Router.map(function() {' + EOL
});
// app/router.js
Router.map(function() {
  this.route("admin");
});

Parameters:

Name Type Attribute Description
pathRelativeToProjectRoot String
contentsToInsert String
providedOptions Object

Return:

lib/utilities/will-interrupt-process.js:118

public setupSignalsTrap( )

Sets up listeners for interruption signals

When one of these signals is caught than raise process.exit() which enforces capture-exit to run registered interruption handlers

lib/utilities/will-interrupt-process.js:136

public teardownSignalsTrap( )

Removes interruption signal listeners and tears down capture-exit

lib/utilities/will-interrupt-process.js:151

public trapWindowsSignals( )

Suppresses "Terminate batch job (Y/N)" confirmation on Windows

Private Methods

lib/utilities/windows-admin.js:106

private _checkForElevatedRights(ui): Object

Uses the eon-old command NET SESSION to determine whether or not the current user has elevated rights (think sudo, but Windows).

Parameters:

Name Type Attribute Description
ui Object
  • ui object used to call writeLine();

Return:

Object

Object describing whether we're on windows and if admin rights exist

sets up a WindowsSymlinkChecker

providing it with defaults for:

  • if we are on windows
  • if we can symlink
  • a reference to exec

Parameters:

Name Type Attribute Description
UI UI

Add process interruption handler

When the first handler is added then automatically sets up process interruption signals listeners

Parameters:

Name Type Attribute Description
cb Function

Callback to be called when process interruption fired

lib/tasks/test-server.js:61

private onInterrupt( )

Exit silently

lib/tasks/serve.js:75

private onInterrupt( )

Exit silently

Drops all the interruption handlers and disables an ability to add new one

Note: We don't call `captureExit.releaseExit() here. In some rare scenarios it can lead to the hard to debug issues. see: https://github.com/ember-cli/ember-cli/issues/6779#issuecomment-280940358

We can more or less feel comfortable with a captured exit because it behaves very similar to the original exit except of cases when we need to do cleanup before exit.

lib/utilities/will-interrupt-process.js:95

private removeHandler(cb)

Remove process interruption handler

If there are no remaining handlers after removal then clean up all the process interruption signal listeners

Parameters:

Name Type Attribute Description
cb Function

Callback to be removed