Skip to content
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

Publishing finishes with async with no result #207

Open
st3vo7 opened this issue Nov 10, 2022 · 0 comments
Open

Publishing finishes with async with no result #207

st3vo7 opened this issue Nov 10, 2022 · 0 comments

Comments

@st3vo7
Copy link

st3vo7 commented Nov 10, 2022

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.

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

No branches or pull requests

1 participant