Skip to content

Publishing finishes with async with no result #207

@st3vo7

Description

@st3vo7

Without async/await, publishing to s3 results in

 Starting 'publishTechnicalDocumentationInternalS3'...
 The following tasks did not complete: publishTechnicalDocumentationInternalS3
 Did you forget to signal async completion?

When declaring it as async, and awaiting it, the compiler returns success in 13ms, but no resulting files on s3 can be found.

export const publishS3 = async function (module, version)  {
    // create a new publisher using S3 options
    // http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#constructor-property
    const publisher = awspublish.create(
        {
            signatureVersion: 'v4',
            accessKeyId: '<MyKeyId>',
            secretAccessKey:  '<MyKeySecret>',
            params: {
                Bucket:  '<MyBucket>',
            },
        },
        {
            cacheFileName: 'cache',
        },
    );

    // define custom headers
    const headers = {
        'Cache-Control': 'max-age=315360000, no-transform, public',
        'x-amz-acl': 'public-read',
    };
    let prefix =  '<MyPrefix>';
    if (prefix) {
        prefix += '/';
    }
    return gulp
        .src(`./build/site/${module.toLowerCase()}/${version}/**`)
        .pipe(
            rename(function (path) {
                path.dirname = `${module.toLowerCase()}/${prefix}${path.dirname}`;
            }),
        )
        .pipe(parallelize(publisher.publish(headers), 10))
        .pipe(publisher.sync(`${module.toLowerCase()}/${prefix}`))
        .pipe(publisher.cache())
        .pipe(awspublish.reporter());
};
export const publishTechnicalDocumentationInternalS3 = async () => await publishS3('Technical-Documentation', 'internal');

So, the outcome is:

Using gulpfile ~/Documents/Limecraft/technical-documentation/gulpfile.js
 Starting 'publishTechnicalDocumentationInternalS3'...
 Finished 'publishTechnicalDocumentationInternalS3' after 11 ms

I guess it's the issue with streams and promises, and although I tried a couple of approaches (generating a Promise on my own, using stream-to-promise library), none of them seem to be working.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions