-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
t2 run: move JS-specific "post run" operation to a language specific definition #787
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,11 +63,21 @@ var exportables = { | |
lists: lists, | ||
}; | ||
|
||
|
||
exportables.preBundle = function(opts) { | ||
return exportables.resolveBinaryModules(opts); | ||
/* | ||
exportables.preRun = function(tessel, options) { | ||
return Promise.resolve(); | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not removed, just relocated next to |
||
*/ | ||
|
||
exportables.postRun = function(tessel, options) { | ||
if (tessel.connection.connectionType === 'LAN') { | ||
// Pipe input TO the remote process. | ||
process.stdin.pipe(options.remoteProcess.stdin); | ||
process.stdin.setRawMode(true); | ||
} | ||
|
||
return Promise.resolve(); | ||
}; | ||
|
||
function logMissingBinaryModuleWarning(name) { | ||
var warning = tags.stripIndent ` | ||
|
@@ -368,18 +378,22 @@ exportables.injectBinaryModules = function(globRoot, tempBundlePath, options) { | |
}); | ||
}; | ||
|
||
exportables.tarBundle = function(opts) { | ||
exportables.preBundle = function(options) { | ||
return exportables.resolveBinaryModules(options); | ||
}; | ||
|
||
exportables.tarBundle = function(options) { | ||
var cwd = process.cwd(); | ||
var target = opts.target || cwd; | ||
var target = options.target || cwd; | ||
var relative = path.relative(cwd, target); | ||
var globRoot = relative || target; | ||
var packer = tar.Pack({ | ||
noProprietary: true | ||
}); | ||
var buffers = []; | ||
|
||
if (opts.full) { | ||
opts.slim = false; | ||
if (options.full) { | ||
options.slim = false; | ||
} | ||
|
||
var includeRules = glob.rules(target, '.tesselinclude') | ||
|
@@ -425,18 +439,18 @@ exportables.tarBundle = function(opts) { | |
// project files themselves. | ||
var tempBundleDir = fsTemp.mkdirSync(); | ||
|
||
if (opts.slim) { | ||
if (options.slim) { | ||
return new Promise((resolve, reject) => { | ||
var absRoot = path.resolve(globRoot); | ||
// Setup for detecting "overlooked" assets (files, directories, etc.) | ||
var common = ['node_modules', 'package.json', '.tesselinclude', opts.resolvedEntryPoint]; | ||
var common = ['node_modules', 'package.json', '.tesselinclude', options.resolvedEntryPoint]; | ||
// These will be compared against the dependency graph | ||
var assets = fs.readdirSync(globRoot) | ||
.filter(entry => (common.indexOf(entry) === -1)) | ||
.map(entry => path.join(globRoot, entry)); | ||
|
||
// Initialize a project for dependency graphing | ||
var entry = path.join(relative, opts.resolvedEntryPoint); | ||
var entry = path.join(relative, options.resolvedEntryPoint); | ||
var project = exportables.project({ | ||
entry: entry, | ||
dirname: globRoot, | ||
|
@@ -485,7 +499,7 @@ exportables.tarBundle = function(opts) { | |
return; | ||
} | ||
|
||
if (opts.single && !dependency.entry) { | ||
if (options.single && !dependency.entry) { | ||
return; | ||
} | ||
|
||
|
@@ -518,7 +532,7 @@ exportables.tarBundle = function(opts) { | |
// where the file in question was actually ignored due to | ||
// an ignore rule. Ultimately, .tesselinclude has the final | ||
// word on any file's inclusion/exclusion | ||
if (!opts.single) { | ||
if (!options.single) { | ||
includeFiles.forEach(file => { | ||
var target = path.join(tempBundleDir, file); | ||
if (!written[target]) { | ||
|
@@ -536,7 +550,7 @@ exportables.tarBundle = function(opts) { | |
log.warn('Some assets in this project were not deployed (see: t2 run --help)'); | ||
} | ||
|
||
exportables.injectBinaryModules(globRoot, tempBundleDir, opts) | ||
exportables.injectBinaryModules(globRoot, tempBundleDir, options) | ||
.then(() => { | ||
var fstream = new Reader({ | ||
path: tempBundleDir, | ||
|
@@ -577,7 +591,7 @@ exportables.tarBundle = function(opts) { | |
// This allows us a safe way to "swap" binary modules. | ||
fs.copySync(globRoot, tempBundleDir); | ||
|
||
return exportables.injectBinaryModules(globRoot, tempBundleDir, opts) | ||
return exportables.injectBinaryModules(globRoot, tempBundleDir, options) | ||
.then(() => { | ||
var fstream = new Ignore({ | ||
basename: '', | ||
|
@@ -595,7 +609,7 @@ exportables.tarBundle = function(opts) { | |
fstream.addIgnoreRules(includeNegateRules); | ||
} | ||
|
||
if (!opts.single && includeFiles.length) { | ||
if (!options.single && includeFiles.length) { | ||
// Instead of making a complete subclass of Ignore (as is done in fstream-npm, | ||
// https://github.com/npm/fstream-npm/blob/master/fstream-npm.js#L91-L183), | ||
// we'll over-ride the just the `applyIgnores` method for cases where there | ||
|
@@ -609,8 +623,8 @@ exportables.tarBundle = function(opts) { | |
}; | ||
} | ||
|
||
if (opts.single) { | ||
fstream.addIgnoreRules(['*', '!' + opts.resolvedEntryPoint]); | ||
if (options.single) { | ||
fstream.addIgnoreRules(['*', '!' + options.resolvedEntryPoint]); | ||
} | ||
|
||
// This ensures that the remote root directory | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just renaming, nothing interesting