Skip to content
This repository has been archived by the owner on Aug 19, 2019. It is now read-only.

Add emission of published files #57

Merged
merged 7 commits into from
Jun 22, 2017
Merged

Add emission of published files #57

merged 7 commits into from
Jun 22, 2017

Conversation

Niksko
Copy link
Contributor

@Niksko Niksko commented Jun 10, 2017

This adds an option which allows you to emit published to the stream. This is incredibly useful because it neatly encapsulates publishing your code to a temporary directory and then returning a stream of the published files. This makes it easy to pipe the stream into other gulp plugins to perform further work on the published files.

As discussed in issue #46, this adds the following functionality:

  • an emitPublishedFiles option which causes the published files to be emitted by the plugin. Setting this to true causes the required msbuild options to be added to the msbuild command that enables a filesystem publish to a the provided directory
  • an accompanying option, publishDirectory which controls where the files are published to on the filesystem. If this option is not specified, the publishDirectory defaults to a directory inside the system temp folder, with a folder name based on a uuid v4

I have added some unit tests of this functionality, but feel free to suggest more.

This adds an option to emit published files, along with associated
configuration changes.

The constants file receives a number of new default values for options
related to this feature.

The command builder uses these options to extend the properties object
if the emitPublishedFileds option is true. Note that the PublishUrl
defaults to a uuid.v4.

Finally, the msbuild-runner library is updated to emit the published
files if the emitPublishedFiles flag is true. In order to do this, it
needs access to the top level through2 stream that this plugin creates.
To accomodate this, the call to startMsBuildTask now accepts a stream
parameter, which allows us to pass the through2 stream down and have
files emitted by it. This also requires updates to the unit tests, in
order to accomodate the change of parameter order.
This changes the publishUrl option to be called publishDirectory, based
on the naming discussed in the issue that I raised around this.

This also moves the assignment of a default value to the constants.js
file instead of in the command builder.
This adds a simple test that ensures that when the emitPublishedFiles
option is set to true, the correct msbuild command is generated.
This adds some proper unit tests that test our new functionality. Based
on these tests I fixed a few small typos and logic errors.

There's still a todo here that needs some work. I'm not really sure why
I can't get the calledWith assertion to work on the objects passed to
mockStream.push, but I would like to have proper coverage there before
merge.
This adds a working unit test for the stream push. We also point to the
correct location of the publish directory on the options object.
We don't need to join the path to the destination, since our glob now
returns the absolute path of the generated file.
Since the glob function is asynchronous, we don't want to call the
callback until it has finished executing. With the callback in the
original location, the stream was emitting the end event before the
glob had pushed files into the stream.

This correctly puts the call to the through2 callback inside the glob
callback, and updates the unit tests accordingly.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 98.773% when pulling 58b432a on Niksko:master into a549abc on hoffi:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 98.773% when pulling 58b432a on Niksko:master into a549abc on hoffi:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 98.773% when pulling 58b432a on Niksko:master into a549abc on hoffi:master.

@Niksko
Copy link
Contributor Author

Niksko commented Jun 10, 2017

Apologies, this should probably be a PR into develop

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants